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!

Problem with Macro reading Product properties description with full file path

Status
Not open for further replies.

Barnon

Mechanical
Jul 23, 2016
97
US
I'm trying to read the description of product file from the drawing for our title block program.
If I run the Macro below I get an Error at "Set productDocument1 = documents1.Item(Str)" complaining "the method Item failed". If I just enter the file name "Set productDocument1 = documents1.Item("filename.CATProduct") it works as long as the product is in the same directory as the drawing I have up at the time. But our files are located in a bunch of different directories so I need to enter the full path.


Language="VBSCRIPT"

Sub CATMain()

Dim documents1 As Documents
Dim Str as String
Set documents1 = CATIA.Documents

Dim productDocument1 As Document
Str = "V:\V_Projects\batterypack AA\Product14.CATProduct"
Set productDocument1 = documents1.Item(Str)

Dim product1 As Product
Set product1 = productDocument1.Product

'product1.DescriptionRef = "This is the New DDDescription"
msgbox product1.DescriptionRef
End Sub
 
Replies continue below

Recommended for you

Hi,
so how can you even know where are those parts? If they are in different folders?

Can you read it when product is closed? I made some similar macro, but i had opened product to take parameters.

 
I'm new to Catia so I'm quite ignorant with macros. I just copy and paste scrips I find.

I read the link at the drawing level:

I do need the part open, not displayed. (just checked it. didn't realize it since I always had it open.)

Looks like my only issue is with one line below. Adding full path causes the line to fail.

Set productDocument1 = documents1.Item("Product14.CATProduct") (Works)
Set productDocument1 = documents1.Item("V:\V_Projects\batterypack AA\Product14.CATProduct") (Fails)
 
With further testing it looks like I'll just call out the filename since it needs to be loaded anyway.

I'm good for now.

Thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top