×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Problem with Macro reading Product properties description with full file path

Problem with Macro reading Product properties description with full file path

Problem with Macro reading Product properties description with full file path

(OP)
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

RE: Problem with Macro reading Product properties description with full file path

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.

http://catiavbmacro.com

RE: Problem with Macro reading Product properties description with full file path

(OP)
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:
http://www.coe.org/p/fo/et/thread=28292

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)

RE: Problem with Macro reading Product properties description with full file path

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources

White Paper: Rapid Manufacturing with FDM
The automotive industry is increasingly turning to additive manufacturing, and fused deposition modeling (FDM) specifically, as a reliable alternative to traditional metal-cutting methods, like milling, turning and boring. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close