Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some questions about macro programing

Status
Not open for further replies.

AtomicNico

Nuclear
May 10, 2016
62
Hello everybody,

As you can see I'm new to this forum and I browsed it searching for my answers and unfortunately I didn't find it, so here I am!

-Can you change of workbench while you're executing a macro through the "CATIA.StartWorkbench ("name of workbench")?
Like I want to extract some datas in analysis workbench then change of workbench to extract mass, all of that in 1 macro

- What is the differences between Product and ArrangementProduct when you declare something? And sometimes I can see
objArrRun As Run​
objArrRuns As Run[highlight #EF2929]s[/highlight]​
Is there a difference? Putting an S won't make a difference?

- For the function .Search, I saw some ways to write it and I wanted to the differences and the conditions of writing one or the other:
oSel.Search "'Assembly Design'.Part, all"​
or
oSel.Search "(CATLndSearch.Part),all"​
Does the CAT***Search is depending on the workbench you're currently working in?

- I saw several topics about finding the mass and the inertia through a macro which used the 2 sames ways as I saw on other sites, but when I tried it on my computer, none of them worked, so, in which cases do you use these 2 ways:
Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench(“SPAWorkbench“)
Dim productInertia As Inertia
Set productInertia = TheSPAWorkbench.Inertia.Add(Product)​
and
prdProduct As Part
Dim productInertia As Inertia
On Error Resume Next
Set productInertia = prdProduct.GetTechnologicalObject(“Inertia”)​

FYI, I'm working on a computer where the documentation of CATIA was erased
Sorry if bad english, not my first language.

Best regards
 
Replies continue below

Recommended for you

No, it's a product I'm passing
Set oManager = objProductMat.Item(k).GetItem("CATMatManagerVBExt")
oManager.GetMaterialOnProduct objProductMat,Mat
 
And it doesn't change if I put
Dim objProductMat As Part
or
Dim objProductMat As Product
 
and the material is apply to what?

Eric N.
indocti discant et ament meminisse periti
 
ok i did test your code and I have the same problem

Code:
oManager.GetMaterialOnProduct objProductMat,Mat

does not find material on the product if the product is a part instance... you' ll have to work with the part

so use:

Code:
oManager.GetMaterialOnPart objProductMat.ReferenceProduct.Parent.Part,Mat

Be aware that this line will fail if objProductMat is not an instance

Eric N.
indocti discant et ament meminisse periti
 
Ok, thanks Eric, I will try it Tuesday when I come back to the office but what is an instance exactly?
 
this is 3dx 2016X but V5 logic is the same:

2016-05-14_14-47-02_j5ea88.png


Eric N.
indocti discant et ament meminisse periti
 
Ok I'm back to work and I tried the modification, I still can't get the material even though I think i have the same configuration as you (with what I think is an instance)
download.aspx
 
where is the error message / line?

Eric N.
indocti discant et ament meminisse periti
 
REMOVE ALL ON ERROR RESUME NEXT !

ALL OF THEM

Eric N.
indocti discant et ament meminisse periti
 
The error is still on the GetItem method then

Ps: I'm sorry, I'm extracting other things and at each try I'm adding something, and I put the On Error back to try the other informations
 
use VBA debug tool (Locals) to make sure variable are Dimed properly use V5Automation.chm as reference in chapter : Applying or Retrieving a Material on a Product, a Part, or a Body

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor