Danke für den hinweis
Aber eine Funktion für rechtecke habe ich nun nicht gefunden.
Dort wird nur ein Kreis beschrieben.
Auf grund dessen, habe ich nun für Rechtecke folgendes gemacht:
Status = Document.Indicate2D("Indicate first point buttom left", WindowLocation)
If (Status = "Cancel") Then
MsgBox "Macro interrupted by User" Exit Sub
End If
X0 = WindowLocation(0)
Y0 = WindowLocation(1)
InputObjectType(0) = "Point2D"
Status = "MouseMove": TempRect = 0
Status = Selection.IndicateOrSelectElement2D("Indicate second point top right", _
InputObjectType, False, False, True, _
ObjectSelected, WindowLocation)
If (Status = "Cancel") Then
MsgBox "Macro interrupted by User"
Exit Sub
End If
' We loop onto mouse moves without click
Dim Line2D(3)
Do While (Status = "MouseMove")
If (TempRect) Then
Selection.Add Line2D(0)
Selection.Add Line2D(1)
Selection.Add Line2D(2)
Selection.Add Line2D(3)
Selection.Delete
End If
Set Line2D(0) = Factory2D.CreateLine(X0, Y0, WindowLocation(0), Y0)
Line2D(0).Name = "TempRect"
Set Line2D(1) = Factory2D.CreateLine(WindowLocation(0), Y0, WindowLocation(0), WindowLocation(1))
Line2D(1).Name = "TempRect"
Set Line2D(2) = Factory2D.CreateLine(WindowLocation(0), WindowLocation(1), X0, WindowLocation(1))
Line2D(2).Name = "TempRect"
Set Line2D(3) = Factory2D.CreateLine(X0, WindowLocation(1), X0, Y0)
Line2D(3).Name = "TempRect"
TempRect = 1
Status = Selection.IndicateOrSelectElement2D("Indicate second point top right", _
InputObjectType, False, False, True, _
ObjectSelected, WindowLocation)
If (Status = "Cancel") Then
Set drawingDocument1 = CATIA.ActiveDocument
Set selection2 = drawingDocument1.Selection
selection2.Search "Name=TempRect,all"
selection2.Delete
selection2.Clear
MsgBox "Macro interrupted by User"
Exit Sub
End If
Loop
X1 = WindowLocation(0)
Y1 = WindowLocation(1)
Damit ist auch gleich ein error handling drinn, denn das hat in dem beispiel gefehlt.
Eventuell ist in diesem code auch ein wenig müll drinn, den muss ich erst aufräumen...
Vielleicht braucht das ja wer mal....oder weis wie man direkt ein Rechteck abrufen kann
Jedenfalls für den Hinweis gibts 5 Unitis
------------------
Non in omnes omnia conveniunt
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP