Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Identify a CATIA Component from a CATIA Product 1

Status
Not open for further replies.

Suncad

Mechanical
Oct 30, 2013
44
FR
Hi there,

I'm working on a CATIA macro that need to check wether the current product is a real product (with its own .CATProduct file) or a component. The tree icon is different, so this must be stored somewhere...

ex :

for i = 1 to prod_count

if CurrentProd.Products.Item(i) <<is a product>> then
<<do stuffs>>
else

if CurrentProd.Products.Item(i) <<is a component>> then
<<do other stuffs>>
end if
end if


Thanks if you can help me,

Victor
 
Replies continue below

Recommended for you

Hi

Code:
Language="VBSCRIPT"
Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set products1 = product1.Products

For i = 1 To products1.Count
NameOfProdPart = products1.Item(i).ReferenceProduct.Parent.Name

If Right(NameOfProdPart,7) = "CATPart" Then
Msgbox "Part! " & NameOfProdPart
Elseif Right(NameOfProdPart,7) = "Product" Then

If NameOfProdPart = product1.Name & ".CATProduct" Then
Msgbox "Component! " & NameOfProdPart
Else
Msgbox "Product! " & NameOfProdPart
End If

End If
Next
End Sub

Regards
Fernando

- Romania
- EU
 
Thank you very much, I did'nt tought it would be that easy.
 

Try to use

sType = TypeName(products1.Item(i))

sType will be "Product", "Part", "Body", "Document", "Hybridbody", ...

Cheers,
Alex


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top