Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create and Rename Layer in CATIA Drawing Using VBA

Status
Not open for further replies.

nhhv230

Aerospace
Aug 28, 2007
3
0
0
US
Hi All,

I'm trying to find a way in CATIA V5 CATDrawing to create and rename layers using VBA.
I have found through other post to change the layer of geometric elements. See attached text file.
But even though the layer of the geometries are already changed, it does not show in the list of layers.

2019-12-09_095540_zvtvom.jpg


2019-12-09_095605_ohg1go.jpg


2019-12-09_095635_egov6x.jpg


Is there a way to make the 'new' layer visible in the list by using VBA?
And secondly, can it also be renamed by using VBA?

2019-12-09_095711_eqwgzr.jpg


Thanks in advance.
 
Replies continue below

Recommended for you

Apologies,

I don't seemed to be able to attach the text file.
So here is what I used to change the layer of geometric elements:

Sub DrawingModule()

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument

Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets

Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.Item("Model")

Dim drawingViews1 As DrawingViews
Set drawingViews1 = drawingSheet1.Views

Dim drawingView1 As DrawingView
Set drawingView1 = drawingViews1.Item(3)

Dim geomElem1 As GeometricElements
Set geomElem1 = drawingView1.GeometricElements

Dim selection1 As Selection
Set selection1 = CATIA.ActiveDocument.Selection

selection1.Clear

For Each gm In geomElem1
selection1.Add gm
Next gm

Set visProperties1 = selection1.VisProperties
visProperties1.SetLayer catVisLayerBasic, 2
visProperties1.SetRealColor 0, 0, 255, 1

drawingSheet1.Update

End Sub
 
Status
Not open for further replies.
Back
Top