Zitat:
Dim scheint mir eine variablendeklaration zu sein, ich hab schon Makros gesehen, da wird das nicht verwendet. Wann brauch ich das?
richtig, man muss die variablen nicht deklarieren. dann werden sie von vb automatisch als variant deklariert wenn sie das erste mal verwendet werden. Wenn du das "As" weglässt wird die variable ebenfalls als variant deklariert. variant variablen kann man alle datentypen zuweisen, allerdings sind sie nicht gerade speicherschonend.. daher sollte man alles deklarieren, soweit es geht. manchmal muss man allerdings variant oder object datentypen verwenden in catia (z.b. bei restricted interfaces).
"Set" verwendet man bei variablen, denen man ein objekt zuweist.
Objektzuweisung:
Dim ActiveDoc as Document
Set ActiveDoc = CATIA.ActiveDocument
Datentyp ganze zahlen, kein objekt:
Dim Nummer as Integer
Nummer = 5
Zitat:
Die struktur dahinter wird mir allerdings nicht ganz klar. warum mal mit GetItem, warum mal nur mit Item? gibts da vll irgendeine vorgehensweise?
Func GetItem( CATBSTR IDName) As CATBaseDispatch
Returns an object from its name.
Role: To retrieve an object when only its name is available. You should not use this method, but you can find it in the macros generated by the Tools->Macro command.
Func Item( CATVariant iIndex) As CATIAActivity
This method gets the specified activity on the current activities management.
also GetItem nur da verwenden, wo es nicht anders geht. oft hilft nur ausprobieren.
Zitat:
dann mit .name wird eine Funktion aufgerufen, die den namen ändert?
Property Name( ) As CATBSTR (Read Only)
Returns or sets the name of the object. The name is a character string you can assign to any object to handle it easier. In the case of an object part of a collection, the name can often be used in place of the object rank to retrieve or remove the object, providing the Item and Remove methods of the collection feature an argument with the Variant type. If the object has no name set, the name returned is the one of its parent.
.name kann also den namen abrufen oder ihn ändern.
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP