AlexMorasan
Automotive
- Aug 17, 2020
- 13
Hello everyonge
I am creating a macro that creates a Plane (Angle/Normal to Plane) and a Line (Angle/Normal to Curve) after the user selects a point and a curve. To inform the user about what he/she needs to select my code shows a MsgBox with the proper instructions.
Examplo, the user runs the macro, the following Msgbox appears requesting the user to select a curve.
After the user selects the curve then a new Msgbox appears a request the selection of a point, then the macro creates the geometry.
I am trying to improve my macro by adding a userform, like the following picture. However, I am not sure how to activate the SelectElement2 function right after the userform appears.
For example when you add a plane in CATIA you press the button , the userform appears and you can immediately select your references to create the plane. I want my macro to function in a similar way, any ideas about how I can do it ? If you need to see my code I ll provide it ASAP.
So far I only tried o put this code , but it did not work
Private Sub UserForm_Initialize()
Set USel = CATIA.ActiveDocument.Selection
Set USelLB = USel
MsgBox "Select in the Specification tree the part where the tangency will be created. Press ESC to cancel"
oStatus = USelLB.SelectElement2(PartObject, "Select something in Specification Tree", False)
If (oStatus = "Cancel") Then
Exit Sub
Else
End If
Selected_Part = USel.Item(1).Value.Name
USel.Clear
End Sub
Thanks in advance for your help.
I am creating a macro that creates a Plane (Angle/Normal to Plane) and a Line (Angle/Normal to Curve) after the user selects a point and a curve. To inform the user about what he/she needs to select my code shows a MsgBox with the proper instructions.
Examplo, the user runs the macro, the following Msgbox appears requesting the user to select a curve.
After the user selects the curve then a new Msgbox appears a request the selection of a point, then the macro creates the geometry.
I am trying to improve my macro by adding a userform, like the following picture. However, I am not sure how to activate the SelectElement2 function right after the userform appears.
For example when you add a plane in CATIA you press the button , the userform appears and you can immediately select your references to create the plane. I want my macro to function in a similar way, any ideas about how I can do it ? If you need to see my code I ll provide it ASAP.
So far I only tried o put this code , but it did not work
Private Sub UserForm_Initialize()
Set USel = CATIA.ActiveDocument.Selection
Set USelLB = USel
MsgBox "Select in the Specification tree the part where the tangency will be created. Press ESC to cancel"
oStatus = USelLB.SelectElement2(PartObject, "Select something in Specification Tree", False)
If (oStatus = "Cancel") Then
Exit Sub
Else
End If
Selected_Part = USel.Item(1).Value.Name
USel.Clear
End Sub
Thanks in advance for your help.