Hallo Zusammen,
ich Versuche gerade anhand von einem Punkt und einer Fläche ein Linie zu erzeugen, die Normal zur Fläche sein soll. Für die einfachere Handhabung habe ich mich entschieden eine Userform zu erstellen. Der Punkt und die Fläche werden in einem seperaten "Private Sub" ausgewählt. Dies funktioniert so weit. Jedoch kann ich die Eingaben in einem weiteren Private Sub nicht verwenden. Woran liegt das? Bzw. wo ist mein Fehler?
Der Code sieht wie folgt aus:
'********** select starting point *******************************************************
Private Sub select_starting_point_Enter()
Dim Selected_starting_point As Object
If CATIA.Documents.Count = 0 Then
MsgBox "There is no CATIA Part file open. Open a Part file and try agian", , msgboxtext
Unload Userform
Exit Sub
End If
If InStr(CATIA.ActiveDocument.Name, ".CATPart") < 1 Then
MsgBox "Active CATIA Document is not a Part. Open a Part file and try again.", , msgboxtext
Unload Userform
Exit Sub
End If
Userform.Hide
'*** select options ***
Dim Filter(1)
Filter(0) = "Point"
Filter(1) = "Point2D"
'*** define selection and clear it ***
Dim UserSel As Object
Set UserSel = CATIA.ActiveDocument.Selection
UserSel.Clear
'*** define selection ***
Dim sp As String
sp = UserSel.SelectElement2(Filter, ">>>>>>>>>> select starting point <<<<<<<<<<", True)
If sp = "Normal" Then
Set Selected_starting_point = UserSel.Item(1).Value
UserSel.Clear
Else
Exit Sub
End If
Userform.Show
End Sub
'********** select surface ************************************************************
Private Sub surface_Enter()
Dim Selected_surface As Object
If CATIA.Documents.Count = 0 Then
MsgBox "There is no CATIA Part file open. Open a Part file and try agian", , msgboxtext
Unload Userform
Exit Sub
End If
If InStr(CATIA.ActiveDocument.Name, ".CATPart") < 1 Then
MsgBox "Active CATIA Document is not a Part. Open a Part file and try again.", , msgboxtext
Unload Userfrom
Exit Sub
End If
Userform.Hide
'*** select options ***
Dim Filter(13)
Filter(0) = "HybridShapeInverse"
Filter(1) = "HybridShapeSurfaceExplicit"
Filter(2) = "HybridShapeAssemble"
Filter(3) = "HybridShapeFill"
Filter(4) = "HybridShapeSweep"
Filter(5) = "HybridShapeSymmetry"
Filter(6) = "HybridShapeExtractMulti"
Filter(7) = "HybridShapeExtract"
Filter(8) = "HybridShapeExtrude"
Filter(9) = "HybridShapeOffset"
Filter(10) = "HybridShapeSplit"
Filter(11) = "HybridShapeTrim"
Filter(12) = "HybridShapeTranslate"
Filter(13) = "HybridShapeRotate"
'*** define selection and clear it ***
Dim UserSel As Object
Set UserSel = CATIA.ActiveDocument.Selection
UserSel.Clear
'*** define selection ***
Dim surface As String
surface = UserSel.SelectElement2(Filter, ">>>>>>>>>> select surface for part marking <<<<<<<<<<", True)
If surface = "Normal" Then
Set Selected_surface = UserSel.Item(1).Value
surface_for_part_marking.Value = Selected_surface.Name
surface_for_part_marking.Locked = True
surface_for_part_marking.BackColor = &HC0C0C0
UserSel.Clear
Else
Exit Sub
End If
Userform.Show
End Sub
'********** Final Line *******************************************************
Privat Sub Final_Line_Enter()
Set docs = CATIA.Documents
Set cad2 = CATIA.ActiveDocument
Set sel2 = cad2.Selection
Set hsf2 = cad2.Part.HybridShapeFactory
Set hb1 = cad2.Part.HybridBodies
Set vis2 = cad2.Selection.VisProperties
Set spa2 = cad2.GetWorkbench("SPAWorkbench")
Set prt2 = cad2.Part
Set bodies1 = prt2.Bodies
Set axisSyst2 = prt2.AxisSystems
Set hb2 = prt2.HybridBodies.Add()
Dim surOut(999), lnOut(999)
demo = 0
On Error GoTo 0
Set InNormal = hsf2.AddNewLineNormal (Selected_surface, Selected_starting_point, 10.00, -10.00, False)
hb2.AppenedHybridShape InNormal
End Sub
Würde mich mega freuen, wenn jemand mir weiterhelfen könnte.
------------------
---
nichts geschieht ohne risiko aber ohne risiko geschieht nichts
[Walter Scheel]
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP