×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

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!

*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

VBA Catia: CATParts in a CATProduct considered as Product Objects

VBA Catia: CATParts in a CATProduct considered as Product Objects

VBA Catia: CATParts in a CATProduct considered as Product Objects

(OP)
Evening all,
I've written a bit of VBA code to play with CATParts for the automation of copy/paste bodies and operate transformations such as splits etc.
When i try to adapt this to a CATProduct i cant seem to be able to get the Part Porperties/Methods i had in my former code.
Let's say i have a CATProduct made of a CATPart and a sub-CATProduct (made of 4 CATParts itself).

This is the beginning of my code:
...................................................
Set partdocument1 = CATIA.ActiveDocument
Set product1 = partdocument1.Product

Set part1 = product1.Products.Item(1)
Set subproduct1 = product1.Products.Item(2)

Set subproduct1_part1 = subproduct1.Products.Item(1)
Set subproduct1_part2 = subproduct1.Products.Item(2)
Set subproduct1_part3 = subproduct1.Products.Item(3)
Set subproduct1_part4 = subproduct1.Products.Item(4)
....................................................

All the above end up being Product Objects even though they clearly have nothing under them apart from product1 and subproduct1 (e.g. part1.Products.Count = 0). I have tried ActivateShape and DesignMode with no success.

Could you help me getting hold of the actual Part Properties/Methods when i've reached a CATPart (i.e. get to Bodies, ShapeFactories etc...)? This way i could navigate in my tree and perform operation within the Parts i want to modify.
The way around it would be to grab the CATParts full name and open them in a new window, save, close and update product1 but i'm sure there is a smarter way to do it within one single window.

Thanks for your support !



 

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

Which program and version are you working in?

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

(OP)
Microsoft Excel 2000
Catia V5 R18
________________________________________

My Catia tree looks like this:

product1
   |_ part1
   |_ subproduct1
        |_ subproduct1_part1
        |_ subproduct1_part2
        |_ subproduct1_part3
        |_ subproduct1_part4

 

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

AeroBouquito

I'm not familiar with CATIA.  Is this something you accessing through an Excel add-in, pulling in files, or are you trying to reference another program.

The methods you want might not be available without setting the reference library in the VBE.  From the visual basic editor select TOOLS > References > then see if you can scroll down and find a reference library for CATIA.

If this happens to be the case then, after setting the reference library, you should be able to dig through the object browser and find what properties and methods are available to you.

-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

Sorry about the grammar of that second sentence.  That should be a question,

"Is this something you are accessing through an Excel add-in, pulling in CATIA data files, or are you trying to reference another program through the Excel environment?"

-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

(OP)
JTBorton,

Thanks for your reply. I had all those references set already and had tried to navigate through the object browser. My tool work perfectly well with CATPArt files but it's only when trying to access CATPart via a CATProduct that i cannot access the correct methods and properties, as CATProducts children are by default considered as CATProducts as well(with different methods and properties from CATParts).

I think im gonna go banging my head against a wall then !

If anyone else has a solution to my issue, please let us know !!

Thanks !

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

(OP)
... sorry i forgot to answer your question in the end.
Yes, i do run my VBA script from Excel ... and it goes to read and control an open Application/Window of Catia V5.

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects




Hi,

I am not familiar with CATIA either.  However, I am quite conversant with the objects, properties, methods concept use in VBA.

Does the CATIA Object Model have an object for Part?  

If so, what are some of it's properties & methods?

 

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

AeroBouquito

Bring up VBA in Excel and hit F2. This will bring up the object browser.

If CATIA has exposed any public properties/methods for you to work with, you should be able to see them here.

Note that you may have to add a reference to CATIA under Tools->References

Tim Grote - The Irrigation Engineers.
www.irrigationengineers.com

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

(OP)
Hello,

Thanks for your replies. To answer your questions, yes i have added the References associated to Catia V5 in my Tools/References and can see the methods/properties available for Catia objects through the Object Browser within VBA.

When i run the code step by step i can clearly see my objects being dealt with.

Catia libraries include 2 disctinct Objects for CATParts (Part Objects from Catia Library) and CATProducts (Product Objects from Catia Library). Each of those have different methods/properties. The issue is that for some reason, a Product Object child "HAS GOT TO BE" a Product has well where obviously at some point it will be a Part.

To make some analogy, a CATProduct is like a folder where a CATPart is like a file. I want to dig into my hierarchy of folders to find my files and work on them (products leading to parts). You wouldnt want a file to be considered as a folder just because it's one of the folders children.

I also tried to force the format of both objects but it would lead to a type mismatch, eg:

Dim myProduct as Product
Dim myPart as Part
myPart = myProduct.Products.Item(1)  <--- type Mismatch

Any thought ?

Thanks.

 

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

AeroBouquito:

It may be that because you're using objects you need a set statement, like so:

Dim myProduct as Product
Dim myPart as Part
set myPart = myProduct.Products.Item(1)  'note the 'set'

If that doesn't solve it, it may be that the products collection isn't returning a 'Part', but something else. See if it bombs if you define myPart as a Variant.

Tim Grote - The Irrigation Engineers.
www.irrigationengineers.com

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

(OP)
Hello atook,

I actually forgot to write down the "Set" in my former post. Apologies as i was doing this already in my code. This returns a Type Mismatch error.

I've just tried as you suggested to "Dim myPart as Variant" and the error went away but Part1 was then considered as a Product once again. Grrrrrrrr.
 

RE: VBA Catia: CATParts in a CATProduct considered as Product Objects

Yes, the return item on a products collection should be a product.

Again, I'm not familiar with the object model, but I've an idea you need to be looking for a collection of parts withing a product. Something along the lines of:

Dim myProduct as Product
Dim myPart as Part

set myPart = myProduct.Parts.Item(1)  'note the 'Parts'

Tim Grote - The Irrigation Engineers.
www.irrigationengineers.com

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! Already a Member? Login



News


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