CAD Macro/Automation

Created by ashish kumar on 8 May, 2018

VBA Error : Extraction front view with reference to axis system and its plane.

I am recording a macro but facing an issue while running it.


I created an axis system in 3D.

And now I am extracting a front view by first selecting the axis and then its plane so that UCS of that view will be that axis.


but after recording and running the same program again it is showing an error.

below is the script.


Sub CATMain()


Dim drawingDocument1 As DrawingDocument

Set drawingDocument1 = CATIA.ActiveDocument


Dim drawingSheets1 As DrawingSheets

Set drawingSheets1 = drawingDocument1.Sheets


Dim drawingSheet1 As DrawingSheet

Set drawingSheet1 = drawingSheets1.Item("Sheet.1")


Dim drawingViews1 As DrawingViews

Set drawingViews1 = drawingSheet1.Views


Dim drawingView1 As DrawingView

Set drawingView1 = drawingViews1.Add("AutomaticNaming")


Dim drawingViewGenerativeLinks1 As DrawingViewGenerativeLinks

Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks


Dim drawingViewGenerativeBehavior1 As DrawingViewGenerativeBehavior

Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior


Dim documents1 As Documents

Set documents1 = CATIA.Documents


Dim partDocument1 As PartDocument

Set partDocument1 = documents1.Item("Part1.CATPart")


Dim product1 As Product

Set product1 = partDocument1.GetItem("Part1")


drawingViewGenerativeBehavior1.Document = product1


Dim axisSystem1 As AxisSystem

' No resolution found for the object axisSystem1...


drawingViewGenerativeBehavior1.SetAxisSysteme Nothing, axisSystem1


drawingViewGenerativeBehavior1.DefineFrontView 0#, 1#, 0#, 0#, 0#, 1#


drawingView1.X = 594.5


drawingView1.Y = 420.5


drawingView1.[Scale] = 1#


Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior


drawingViewGenerativeBehavior1.Update


drawingView1.Activate


End Sub



Please check the script and help me out.


Thanks in Advance.