DrawingGenViewProp Not Found On Drawing Service

Marc A Jeeves

DrawingGenViewProp Not Found On Drawing Service

Morning,

I'm writing a vba macro to automatically generate an ISO view in 2020X V6 I'm stuck on the DrawingGenViewProp object and how to get it from the drawing service, am i missing a reference?

 

The Error I'm getting is Object Does not support this property or method when setting Set oGenViewProp = oDrwGenServ.DrawingGenViewProp

thanks

 

Madaxe

 

Sub AddIsoView(CATIA, ReferencePartEditor As Editor, arr As Variant)
'Error handling
On Error GoTo ErrorSub

Dim MyDrawing As DrawingRoot
Set MyDrawing = CATIA.ActiveEditor.ActiveObject
Dim MySheet As DrawingSheet
Set MySheet = MyDrawing.Sheets.ActiveSheet

Dim MyDrawingViews As DrawingViews
Set MyDrawingViews = MySheet.Views

Dim oGenViewFactory 'As DrawingDefineGenView
Set oGenViewFactory = MyDrawingViews.DrawingDefineGenView

Dim myListofPrdInst(0)
Set myListofPrdInst(0) = ReferencePartEditor.ActiveObject.Parent
Dim myProjPlane(5)
myProjPlane(5) = Array(-0.707, 0.707, 0, 0, 0, 1)

' Retrieve the drawing generative service object from the CATIA service
Dim oDrwGenServ As DrawingService
Set oDrwGenServ = CATIA.GetSessionService("CATDrawingService")

' Retrieve a Generative View Properties
Dim oGenViewProp 'As DrawingGenViewProperties
Set oGenViewProp = oDrwGenServ.DrawingGenViewProp

Dim o3DPLMToDraw As VPMRootOccurrence
Set o3DPLMToDraw = ReferencePartEditor.ActiveObject

 

Dim MyNewIsoView As DrawingView
Set MyNewIsoView = oGenViewFactory.DefineIsometricView(10, 10, myListofPrdInst, myProjPlane, "", True, oGenViewProp)

'Error handling
GoTo EndSub
ErrorSub:
MsgBox Err.Description
EndSub:
End Sub

Edited By:
Marc A Jeeves[Gulfstream Aerospace Corporation] @ Jul 11, 2022 - 09:42 AM (America/Central)

Marc A Jeeves

RE: DrawingGenViewProp Not Found On Drawing Service
(in response to Marc A Jeeves)

The problem was i need to use the "CATDrawingGenService" to create a DrawingGenService not DrawingService

Anyway here is the working code below

 

Madaxe

 

Dim oDrwGenServ As DrawingGenService
Set oDrwGenServ = CATIA.GetSessionService("CATDrawingGenService")

 

Sub AddIsoView(CATIA, ReferencePartEditor As Editor)
'Error handling
On Error GoTo ErrorSub

Dim MyDrawing As DrawingRoot
Set MyDrawing = CATIA.ActiveEditor.ActiveObject
Dim MySheet As DrawingSheet
Set MySheet = MyDrawing.Sheets.ActiveSheet

Dim MyDrawingViews As DrawingViews
Set MyDrawingViews = MySheet.Views

Dim oGenViewFactory 'As DrawingDefineGenView
Set oGenViewFactory = MyDrawingViews.DrawingDefineGenView

Dim myListofPrdInst(0)


If (TypeName(ReferencePartEditor.ActiveObject) = "Part") Then
Set myListofPrdInst(0) = ReferencePartEditor.ActiveObject.Parent.Father
ElseIf (TypeName(ReferencePartEditor.ActiveObject) = "VPMRootOccurence") Then
Set myListofPrdInst(0) = ReferencePartEditor.ActiveObject
End If


Dim myProjPlane(5)
myProjPlane(0) = -0.707
myProjPlane(1) = 0.707
myProjPlane(2) = 0
myProjPlane(3) = 0
myProjPlane(4) = 0
myProjPlane(5) = 1

' Retrieve the drawing generative service object from the CATIA service
Dim oDrwGenServ As DrawingGenService
Set oDrwGenServ = CATIA.GetSessionService("CATDrawingGenService")

' Retrieve a Generative View Properties
Dim oGenViewProp As DrawingGenViewProperties
Set oGenViewProp = oDrwGenServ.DrawingGenViewProp

' Create the IsoMetric View
Dim MyNewIsoView As DrawingView
Set MyNewIsoView = oGenViewFactory.DefineIsometricView(-100, -100, myListofPrdInst, myProjPlane, "", True, oGenViewProp)

'Error handling
GoTo EndSub
ErrorSub:
MsgBox Err.Description
EndSub:
End Sub