Więc zanim wstawisz swój blok, będziesz musiał utworzyć i nazwać swój punkt wstawiania, którego będziesz używać zamiast swojego "nic", zobacz ten link, aby utworzyć punkt:
Dim myBlockDefinition As Obiekt Set myBlockDefinition = Part.SketchManager.MakeSketchBlockFromFile(Nothing, "D:\_MAIA\1_MODELES\4_BLOCS-BUFFERS\Tol ISO2768 - EN22768 - mK.SLDBLK", False, 1, 0) Part.EditSheet (Arkusz edycji) Part.EditSketch Part.ClearSelection2 Prawda Koniec subwoofera
Oto makro Vba do wstawiania bloku, wybierając jego punkty współrzędnych:
Dim swApp As Object
Dim swModel As Object
Dim swDrawing As Object
Dim swSheet As Object
Dim swBlockDef As Object
Dim swBlockIns As Object
Sub InsertBlockAtPoint()
' Se connecter à l'application SolidWorks
Set swApp = Application.SldWorks
' Obtenir le document actif (supposé être un dessin)
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "Veuillez ouvrir un document de dessin."
Exit Sub
End If
' Vérifier si le document actif est un dessin
If swModel.GetType <> swDocumentTypes_e.swDocDRAWING Then
MsgBox "Le document actif n'est pas un dessin."
Exit Sub
End If
Set swDrawing = swModel
' Obtenir la feuille active
Set swSheet = swDrawing.GetCurrentSheet
' Spécifier le chemin vers la définition du bloc
Dim blockPath As String
blockPath = "C:\Chemin\Vers\Votre\Bloc.sldblk" ' Changez ceci par le chemin de votre bloc
' Charger la définition du bloc
Set swBlockDef = swDrawing.LoadBlockDefinition(blockPath)
If swBlockDef Is Nothing Then
MsgBox "Échec du chargement de la définition du bloc."
Exit Sub
End If
' Définir les coordonnées du point d'insertion
Dim insertPoint(2) As Double
insertPoint(0) = 0.1 ' Coordonnée X en mètres
insertPoint(1) = 0.1 ' Coordonnée Y en mètres
insertPoint(2) = 0 ' Coordonnée Z (généralement 0 pour les dessins 2D)
' Insérer le bloc au point spécifié
Set swBlockIns = swSheet.InsertBlock(swBlockDef, insertPoint)
If swBlockIns Is Nothing Then
MsgBox "Échec de l'insertion du bloc."
Else
MsgBox "Bloc inséré avec succès."
End If
End Sub
Następnie kilka uwag do kolejnych próśb:
Unikaj wykopywania ofert pracy 2016 Resolute w przyszłości... Zwłaszcza, jeśli któryś z autorów nie publikował ostatnio.