specify a part in product
specify a part in product
(OP)
hi,
I have problem coding the catvba below
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
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
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: specify a part in product
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 -->
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
I'm always trying to find what designers want at the end because this can give you a much more clear idea how to approach the problem.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: specify a part in product
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
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
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
RE: specify a part in product
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
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
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
I use 'CATIA.SystemService.ExecuteScript' in my macro to call a module
thanks anyway