Hello
in SolidWorks
I would like to make a macro vba to insert in a drawing a block quickly, with the click position X Y
in a module, this macro is OK
Sub Note()
Dim swApp As Object
Dim Part As Object
Dim myBlockDefinition As Object
Dim myAnnotation As Object
Dim URL As String
Dim NR As String
Dim NUM As String 'Pas byte sinon bt annulé impossible
Dim REPONSE As String
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
URL = "C:\\Users ...\\"
NUM = InputBox("1 : Tableau découpe insert hexagonal" & vbCrLf & _
"2 : Gousset" & vbCrLf & _
"3 : Soudure" & vbCrLf & vbCrLf & _
"Entrez le numéro du bloc à insérer", "Choix de la note")
Select Case NUM
Case "1": NR = "Découpe_insert_hex.SLDBLK": Echelle = 1: EXT = "A"
Case "2": NR = "Gousset.sldnotestl": EXT = "B"
Case "3": NR = "Soudure.SLDBLK": Echelle = 0.045: EXT = "A"
Case Else: Exit Sub
End Select
REPONSE = URL & NR
If EXT = "B" Then
Set myAnnotation = Part.Extension.InsertAnnotationFavorite(REPONSE, 0, 0, 0)
Else
Set myBlockDefinition = Part.SketchManager.MakeSketchBlockFromFile(Nothing, REPONSE, False, Echelle, 0)
End If
End SubIn userform2
CommandButton1 for OK
TextBox1 for X
TextBox2 for Y
someone to help me coding, I think UserForm2.Show vbModeless
to load and click, grab the x and y position to textbox and validate, and insert at the right position
