Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

CATIA Macro to give Overall Dimensions to a View

AbhishekChavan

Automotive
Mar 2, 2025
5
1746683678342.png

I need a CATIA Macro that can create overall or maximum dimensions of a projected drawing view. The geometrical elements from the view has GenerativeBehaviour associated with it and the objects are named "GeneratedItem" with type View. Therefore, I cannot access the geometrical elements to give Dimensions with Dimensions.Add2 Method. Can anyone help me here?

1746684074846.png


I tried with the below code to return geometrical elements and was planning to use Dimensions.Add2 once I can get the elements as reference.



Code:
Sub MeasureElements()


    Dim drawDoc As DrawingDocument
    Set drawDoc = CATIA.ActiveDocument
    
    Dim drawSheet As DrawingSheet
    Set drawSheet = drawDoc.Sheets.ActiveSheet
    
    Dim drawView As DrawingView
    Set drawView = drawSheet.Views.activeView
    
    Dim geoElements As GeometricElements
    Set geoElements = drawView.GeometricElements
    
    Dim geoElement As GeometricElement
    
    
    
'    For Each geoElement In geoElements
'
'
'        Debug.Print TypeName(geoElement)
'
'
'
'    Next geoElement
'
'
'
'    Debug.Print geoElements.Count
    
    
    
    
    Dim sel1 As Selection
    Set sel1 = drawDoc.Selection
    
    sel1.Add drawView
    
    sel1.Search "Name=GeneratedItem,sel"
    
    
    
    
    For i = 1 To sel1.Count2
    
        Debug.Print TypeName(sel1.Item2(i).Value)
        
    Next i
    
    

End Sub
 
Replies continue below

Recommended for you

 

Part and Inventory Search

Sponsor