obige Fehlermeldung tritt bei der Makro-Programmmierung öfters auf;
insbesondere dann, wenn die Variablen 'Catia-getypt' werden.
(Der Code ist im Wesentlichen vom Makro-Rekorder übernommen.)

Beispiel:


Dim odrVws As DrawingViews
Dim odrVw As DrawingView
Dim oGB1 As DrawingViewGenerativeBehavior
Dim odrVwClip As DrawingView
Dim oGB2 As DrawingViewGenerativeBehavior
Dim double1 As Double
Dim double2 As Double
Dim arrProfile(3)
Dim odrVwGL1 As DrawingViewGenerativeLinks
Dim odrVwGL2 As DrawingViewGenerativeLinks

Set odrVws = CATIA.ActiveDocument.Sheets.ActiveSheet.Views
Set odrVw = odrVws.ActiveView

'section view
Set oGB1 = odrVw.GenerativeBehavior
Set odrVwClip = odrVws.Add("AutomaticNaming")
Set oGB2 = odrVwClip.GenerativeBehavior

odrVwClip.X = 93.922173
odrVwClip.Y = 403.093811

double1 = odrVw.[Scale]
odrVwClip.Scale = 1

double2 = odrVw.Angle
odrVwClip.Angle = 0

arrProfile(0) = 128.848267
arrProfile(1) = 166.59433
arrProfile(2) = 128.848267
arrProfile(3) = 20

Bei der nachfolgenden Zeile tritt der Fehler auf:
oGB2.DefineSectionView arrProfile, "SectionView", "Offset", 0, oGB1

Set odrVwGL1 = odrVwClip.GenerativeLinks
Set odrVwGL2 = odrVw.GenerativeLinks
odrVwGL2.CopyLinksTo odrVwGL1
oGB2.Update

Zur Abhilfe kommen zwei Methoden in Betracht:

1) Variable 'as Object' deklarieren, also statt


Dim oGB2 As DrawingViewGenerativeBehavior


nun


Dim oGB2 As Object


definieren.
Nachteil: IntelliSense-Hilfe geht für oGB2 verloren.

2) Zusätzliche Dummy-Variable vom Typ 'Variant' einführen, z.B.


Dim oGB2Variant  'default Typ ist 'Variant'


Die gleiche Anweisung, jedoch mit dem Dummy-Object


Set oGB2Variant = oGB2   'getypte Variable 'umwandeln' in Variant
oGB2Variant.DefineSectionView arrProfile, "SectionView", "Offset", 0, oGB1


läuft fehlerfrei durch.
Danach kann weiter mit der Catia-getypten Variablen programmiert werden.
Intellisense bleibt erhalten.

Auf voriges Beispiel angewandt:


Dim odrVws As DrawingViews
Dim odrVw As DrawingView
Dim oGB1 As DrawingViewGenerativeBehavior
Dim odrVwClip As DrawingView
Dim oGB2 As DrawingViewGenerativeBehavior
Dim double1 As Double
Dim double2 As Double
Dim arrProfile(3)
Dim odrVwGL1 As DrawingViewGenerativeLinks
Dim odrVwGL2 As DrawingViewGenerativeLinks
Dim oGB2Variant

Set odrVws = CATIA.ActiveDocument.Sheets.ActiveSheet.Views
Set odrVw = odrVws.ActiveView

'section view
Set oGB1 = odrVw.GenerativeBehavior

Set odrVwClip = odrVws.Add("AutomaticNaming")

Set oGB2 = odrVwClip.GenerativeBehavior

odrVwClip.X = 93.922173
odrVwClip.Y = 403.093811

double1 = odrVw.Scale
odrVwClip.Scale = 1

double2 = odrVw.Angle
odrVwClip.Angle = 0

arrProfile(0) = 128.848267
arrProfile(1) = 166.59433
arrProfile(2) = 128.848267
arrProfile(3) = 20

Set oGB2Variant = oGB2
oGB2Variant.DefineSectionView arrProfile, "SectionView", "Offset", 0, oGB1

Set odrVwGL1 = odrVwClip.GenerativeLinks
Set odrVwGL2 = odrVw.GenerativeLinks
odrVwGL2.CopyLinksTo odrVwGL1
oGB2.Update

Bislang hab ich meistens Methode 1 verwendet, sporadisch Methode 2,
allerdings in abgewandelter Form (oDummy as Object).

In Zukunft wird's meist Methode 2 sein.

Tschau,
Joe

Zum Seitenanfang