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!

VBA code to insert the customized symbol in catia drawing which can be replaced using excel file 2

Status
Not open for further replies.

Ajaypatil8458

Aerospace
May 15, 2020
12
IN
Hello,

I have saved some views as a symbol which I am currently in inserting into the CATIA drawing using Catalog option. I need to change these symbols with the input provided in design table excel sheet.

Is there any way to do this with VBA code or for that matter with parametric modelling?


Any help related to this is greatly appreciated.

Thanks,
Vijay
 
Replies continue below

Recommended for you

I am using CATIA V5-6R2017

It should fine then.
Get in touch with your IT department to verify CATIA is installed properly.

Following script should always work:

[script]Option Explicit

Sub CATMain()
MsgBox CStr(CATIA.Documents.Count)
End Sub[/script]
 
Yes below code is working but not the other one which you have posted.

Code:
Option Explicit

Sub CATMain()
MsgBox CStr(CATIA.Documents.Count)
End Sub


Any suggestions.

Regards...Vijay
 
Hi Again,

i have below code where I can replace the 2D component but seleciton of 2D component is manual, any idea how I can do that using 2D component name.

Code:
'---- Begin resolution script for object : 2D Component.1 (Instance)

Set drawingDocument1 = CATIA.ActiveDocument
Set drawingSheets1 = drawingDocument1.Sheets
Set drawingSheet1 = drawingSheets1.Item("Sheet.1")
Set drawingViews1 = drawingSheet1.Views
Set drawingView1 = drawingViews1.Item("Main View")
Set drawingComponents1 = drawingView1.Components
'Set drawingComponent1 = drawingComponents1.Item("2D Component.1 (Instance)")

'---- End resolution script
Dim compsel 'As Selection
Set compsel = drawingDocument1.selection
compsel.Clear
Dim ocomp(0) 'As String
    ocomp(0) = "DrawingComponent"
    Dim Staus
    Status = compsel.SelectElement2(ocomp, "Select 2D-Instance to Replace reference", False)
    If Status = "Cancel" Then
        Exit Sub
    End If
Set drawingComponent1 = compsel.Item(1).Value
compsel.Clear

ocomp(0) = "DrawingView"
Status = compsel.SelectElement2(ocomp, "Select NEW 2D Component View", False)
    If Status = "Cancel" Then
       Exit Sub
    End If
Set drawingView1 = compsel.Item(1).Value
compsel.Clear
compsel.Add drawingComponent1
CATIA.StartCommand "Replace Reference"
'compsel.Clear
'compsel.Add drawingSheets1.Item(2).Views.Item(4)
'compsel.Add drawingView1

Also instead of replace how I can insert the 2D component from catalog using Macro.

Thank you.

regards...Vijay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top