×
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

specify a part in product

specify a part in product

specify a part in product

(OP)
hi,
I have problem coding the catvba below

CODE -->

Dim oDocument As Document
Set oDocument = CATIA.ActiveDocument
 
Dim oProduct As Product
Set oProduct = oDocument.Product

Dim oPart As Part
Set oPart = oProduct.Part

Dim oPoint As Point
Set oPoint = oPart.FindObjectByName(Name) 

so,how to fix this problem?
it seems that oProduct.Part goes wrong,
neither oDocument.Part can work

anyone has solution to this?
please help!

thanks

RE: specify a part in product

(OP)
but what's the point?
now I try to focus on just a part of a product, but catia shows that the line "Set oPart = oProduct.Part" is worng

I don't know if the code behind the line will be the cause of error,
I don't think so, thus I didn't post it here. does it matter?

anyway, I'll try to make this clear
originally I just open a CATpart, and the code was

CODE -->

Dim oDocument As Document
Set oDocument = CATIA.ActiveDocument
 
Dim oPart As Part
Set oPart = oDocument.Part

Dim oPoint As Point
Set oPoint = oPart.FindObjectByName(Name)
.
.
. 

it works,
and then I open a CATproduct containing the part in it,
so I made a change to the code,
I just can't figure out why..
maybe I should code another way, but how?
how to fix it if I open a CATproduct?

RE: specify a part in product

(OP)
so you means that

CODE -->

Set oPart = oProduct.Search("Name='Part1',all") 

is that right or..?
sorry I know little about the language
can you just give me an example or briefly explain how to use this function?


and, I really want to know why can't I type like "Set oPart =oProduct.Part" ?

RE: specify a part in product

Using Search function of this forum you will find for example

http://www.eng-tips.com/viewthread.cfm?qid=368167
http://www.eng-tips.com/viewthread.cfm?qid=343896
http://www.eng-tips.com/viewthread.cfm?qid=97356

and many other threads which can guide you. And check also the v5automation.chm file in your CATIA installation folder.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: specify a part in product

Ferdo is asking what you want to do and what conditions you are working in so he can help you. If he guesses, the solution will likely be incorrect.

So it sounds like you want a macro that will work if you have either a Part or Product loaded? Is that correct?

Dim oDocument as Document
Set oDocument = CATIA.ActiveDocument
Dim oPart as Part
Dim oProduct as Product

If uCase(TypeName(oDocument)) = "PARTDOCUMENT" Then
Set oPart = oDocument.Part
Else if uCase(typename(oDocument)) = "PRODUCTDOCUMENT" Then
Set oProduct as oDocument.Product
'Are you looking for a certain feature in a specific part or are you looking for a certain feature in all the parts in the assembly?
Else
Msgbox "Document type not supported by this macro" & vbCrLf & "Exiting Macro", vbCritical
Exit Sub
End if

RE: specify a part in product

(OP)
thank you
actually it's a module, not macro, I think they are a little different
and I only need to deal with the CATProduct, so 'if...then...' is not necessary


in a specific part, I want to modify the points in a geometry set in it, by FindObjectByName function
by the way, I can't use select command since I want the whole thing to be done automatically

RE: specify a part in product

In fact you need to handle a specific Geometrical Set and not the CATProduct...and then some specific points and not all of them (if I remind well from your older thread).

Best way is when you create them first time, give them specific names, do not let CATIA to name them automatically, in order to search and modify them later on after the name.

And sometimes if-then is it necessary just to prevent user to use the catscript/cavbs/catvba/hta/MSOffice/chm/exe or what ever in the wrong CATIA module. This is a very good practice of programmers, not all users are very careful/interested where they are using macros and then they will ask you why is not working. I have to say that this is a weak point for me, I'm not doing always this and then I have to explain why is not working the macro....

I really like when users like lardman or Alexlozoya or itsmyjob (and many others) are trying to explain why they are programming how you can see here in the forum, I'm learning always something from them (I'm not a professional programmer).

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: specify a part in product

(OP)
now I decide to execute two macros to complete the task...a little bit tiring but much easier since I don't need to care about the syntax of part,product,document...
and I create an icon of Module1, put it in the macro

CODE -->

CATIA.StartCommand("Module1") 

everything goes well when I execute the macro manually in CATIA,
but to my surprise, it gives an error message when I execute the file in a batch mode...
========================
Power input message

Unknown command:Module1
========================
why?
I have tried other command in the macro ,so I am sure that the problem is caused by module
but why? I have created an icon for the module, also I can input "c:Module1" in the command line below,

the problem is : how to open catia files in batch mode and execute the macros and modules?

is it a wrong way to use startcommand("Module1") in the macro when performing the task in batch mode?


RE: specify a part in product

(OP)
finally....it's done
I use 'CATIA.SystemService.ExecuteScript' in my macro to call a module

thanks anyway

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