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!

VBA Objet to Read tor edit the Links in a CADProduct document

Status
Not open for further replies.

JSPROSENG

Mechanical
Aug 7, 2012
5
0
0
US
Does any one know what object in Catia VBA Script can be used to Read and Write to the Linked Documents, in the Assembly or Drawing files of Catia.

Help would be Greatly apprecited. I want to programatically change the absolute path ( the front Part of the Path ) in each of the links, as the documents move from the users Local C Drive Work Space, back to the server, and then as the next user accessed it , modifiy the links via script so all the assembly files or drawing file automatically update all the links, for the next users local hard drive work space,

Thanks

Dana
 
Replies continue below

Recommended for you

Hi,

The bellow CATScript will give you the path but only for first level in the Product. You need to have the CATProduct in Design Mode. If you need more , you have to modify the code. Code is not mine, unfortunately I didn't notice from which forum I get it.

Language="VBSCRIPT"

Sub CATMain()

Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set products1 = product1.Products

For i = 1 To products1.Count

ElementName = products1.Item(i).ReferenceProduct.Parent.Name ' Extract reference name
ElementPath = products1.Item(i).ReferenceProduct.Parent.Path ' Extract reference path
FullPath = ElementPath & "\" & ElementName ' 1 + 1 = 2

If Right(ElementName,7) = "CATPart" Then
Msgbox products1.Item(i).Name & " -> Link (CATPart) -> " & FullPath ' Note products1.Item(i).Name is current instance name
Elseif Right(ElementName,7) = "Product" Then

If ElementName = productDocument1.Name Then
Msgbox products1.Item(i).Name & " -> Link (Component) -> " & FullPath
Else
Msgbox products1.Item(i).Name & " -> Link (CATProduct) -> " & FullPath

End If
End If
Next

End Sub

Regards
Fernando

 
I have since learned that Catia uses links of many types
CCP cut Copy Paste
KWE Knowlede Expert, for Parameters
Instance - for Part to part like adaptivety in INventor or realations in Solid works
View Links for drawings and several others.

I am assuming there is a way to write a VBA to automatically write and read this links from part files, and by know where they are moving to or from, (server or Local), adjust the links in the child files, so that every file knows where to find what it needs.

The folder structure does not change except for the Prefix part of the path. For Example c:\myworkspace\Dan\Project...
may be
c:\myworkspace\Mark|Project on another machine
or
c:\catiafileserver\mainfiles\project on the server

We are NOT using Smart Team and have no plans to.

Any more ideas or examples from anyone would be appreciated to point me in the rightr direction.

Thanks is advance.
 
Status
Not open for further replies.
Back
Top