Hallo Community,
ich habe ein kleinen Testcode geschrieben, weile ich den Zugriff auf Objecte des Typs "DrawingComponent" in ein bestehndes Makro impementieren möchte.
Der Zugriff auf diesen Objecttyp ist ja auch keine problem und eigentlich sollte auch die Abfrage über dessen x und y position kein problem darstellen.
Laut Beschreibung aus der Dokumentation ist das immer mit ".x" oder ".y" möglich.
Auszug aus der Dokumentaition:--------------------------------------------------------------------------------------------------------------------------------------------
o Property x( ) As double
Returns or sets the x coordinate of the drawing component instance position. It is expressed with respect to the view coordinate system. This coordinate, like any length, is measured in millimeters.
Example:
This example sets the x coordinate of the position of the MyComponent drawing component instance to 5 inches. You need first to convert the 5 inches into millimeters.
NewXCoordinate = 5*25.4
MyComponent.x = NewXCoordinate
o Property y( ) As double
Returns or sets the y coordinate of the drawing component instance position. It is expressed with respect to the view coordinate system. This coordinate, like any length, is measured in millimeters.
Example:
This example sets the y coordinate of the position of the MyComponent drawing component instance to 5 inches. You need first to convert the 5 inches into millimeters.
NewYCoordinate = 5*25.4
MyComponent.y = NewYCoordinate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Wenn ich aber mit dieser Methode versuche die Position abzufragen, beschwert sich der Debugger das ein Typ Missmatch vorliegen soll
... Und das Hauptproblem daran ist, das ich wirklich nicht weiß wieso
Ich hoffe Ihr könnt mir bei meinem Problem helfen.
Liebe Grüße
Andy
Nachfolgend noch den Quellcode des Testprogramms (im Anhang sind noch zwei Bilder mit der Fehlermeldung und des Debuggers):
Option Explicit
Public drawingDocument1 As DrawingDocument
Public drawingSheets1 As DrawingSheets
Public drawingSheet1 As DrawingSheet
Public drwViews1 As DrawingViews
Public drwView1 As DrawingView
Public USel
Public MyComp As DrawingComponent
Public PosX As Double
Sub CATMain()
Set drawingDocument1 = CATIA.ActiveDocument 'selection active DRW documents
Set drawingSheets1 = drawingDocument1.Sheets 'select all sheets of active DRW documents
Set drawingSheet1 = drawingSheets1.ActiveSheet 'select the first sheet of the active DRW document
Set drwViews1 = drawingSheet1.Views 'creat a list of all Drawing Views
Set drwView1 = drwViews1.ActiveView 'selection of the first DrawingView
Dim I As Integer
Set USel = CATIA.ActiveDocument.Selection
For I = 1 To USel.Count
If USel.Item(I).Type = "DrawingComponent" Then
MsgBox ("it work")
Set MyComp = USel.Item(I)
PosX = MyComp.x
MsgBox PosX
Else
MsgBox ("don't work")
End If
Next
End Sub
[Diese Nachricht wurde von AndyMattes am 09. Jan. 2023 editiert.]
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP