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!

Convert CATPart in multiple convex parts to be used in 3ds Max 3

Status
Not open for further replies.

rhumaroo

Nuclear
May 25, 2011
3
FI
Hi,

I have just starting using 3ds Max to create some dynamic simulation using models built on CATIA.
As you may know, 3ds Max use only convex shapes in order to simulate dynamic bodies. Just to be clear, a box is a convex shape, while a tube is concave shape. :)

So I have a complex CATPart that basically I have to re-model using multiple convex shapes. And it's very long job when you have complex 3D models. So I would like some tips to simplidy the work.

Does someone know how to divide one CATPart into two, and then as a result you get 2 CATPart into one CATProduct?

I don't know if I am so clear, please let me know and I'll try to formulate it in a different way.
Thanks!
 
Replies continue below

Recommended for you

Depend on how the part was created...if it was created like in old fashion school (meaning like in v4) it will be easy to convert because you will have boolean operations with multiple bodies, easy to convert in simple parts then in one product....
Otherwise is a little complicated, I remember it was a macro which could convert a part with multiple bodies in a catproduct...anyway, this is the ideea, multiple bodies to be converted in simple parts and then in a product....

Regards
Fernando

 
Hi,

Thank you Fernando for your answer.
So if I understood well, for example, you have a CATPart with two cubes inside (simply made out of 2 pads). Is it possible to convert those 2 pads as separated CATParts and then the inital CATPart becomes a CATProduct?

Actually it is just a question of hierarchy in the tree. Moving everything one level up. If such a thing is possible, it would be an improvment for transfering models to 3Ds Max.

Thank you,
Br,
Romain
 
@rhumaroo,ferdo
A macro (or built in tool with CATIA) that allows the functionality to go from CATPart bodies (or features) to CATProduct would be handy for exporting CATIA models to various 3rd party rendering packages like Bunkspeed SHOT too, in addition to programs like Maya and 3DS Max.

I know there is a tool in CATIA that allows you to generate a CATPart from a CATProduct. I think you need the ASD or PDG license to utilize it though. I'm surprised there's not something to do the opposite. If it's not already in CATIA then surely someone out there has already written a macro to do it...

Regards,
Drew Mumaw
 
Hi,

The code below was posted long time ago on catiav5forum.de (which is not existing anymore). I remembered that I have it because I've done a modification to be used also under UNIX OS.

Have fun

Code:
' ==============================================================
' Purpose: A CATPart with multiple bodies inside can be transformed in a CATProduct
' Usage:   1 - You must have a CATPart as active document
'          2 - Run macro 
' Author: gvi70000 (Disclaimer: You use this code at your own risk) 
' ===============================================================

Sub CATMain()
Dim i, n As Integer
Dim name, prt As String
Dim BodyName() As String
Dim partDocument1 As PartDocument
On Error Resume Next
Set partDocument1 = CATIA.ActiveDocument
    If Err.Description = "Type mismatch" Then
        MsgBox "You must have a CATPart as active document"
        Exit Sub
    End If
name = partDocument1.FullName
Dim part1 As part
Set part1 = partDocument1.part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Dim body1 As Body
Dim sel As Selection
Set sel = partDocument1.Selection
Dim documents2 As Documents
Dim partDocument2 As PartDocument
Dim part2 As part
Dim specsAndGeomWindow1 As SpecsAndGeomWindow
n = bodies1.Count
If n = 1 Then
    MsgBox "There is only one body in:" & Chr(13) & name & Chr(13) & "Part MUST have at least 2 Body's" & Chr(13) & "Macro will end now!!!", vbExclamation, "Warning"
Exit Sub
End If
prt = Left(partDocument1.name, Len(partDocument1.name) - 8)
For i = 1 To n
    ReDim Preserve BodyName(i)
    BodyName(i) = prt & "_" & bodies1.Item(i).name
    Set partDocument1 = CATIA.ActiveDocument
    sel.Clear
    sel.Add bodies1.Item(i)
    sel.Copy
    Set documents2 = CATIA.Documents
    Set partDocument2 = documents2.Add("Part")
    partDocument2.Product.PartNumber = BodyName(i)
    Set partDocument2 = CATIA.ActiveDocument
    Set specsAndGeomWindow1 = CATIA.ActiveWindow
    Set part2 = partDocument2.part
    sel.Add part2
    sel.PasteSpecial ("CATPrtResult")
    part2.Update
    Set partDocument2 = CATIA.ActiveDocument
    partDocument2.SaveAs Left(name, Len(name) - Len(partDocument1.name)) & BodyName(i) & ".CATPart"
    specsAndGeomWindow1.Close
    partDocument2.Close
Next 'i
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim productDocument1 As ProductDocument
Set productDocument1 = documents1.Add("Product")
productDocument1.Product.PartNumber = "Product_From_Part_" & Left(partDocument1.name, Len(partDocument1.name) - 8)
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
Dim arrayOfVariantOfBSTR1(0)
Dim constraints1 As Constraints
Set constraints1 = product1.Connections("CATIAConstraints")
Dim reference1 As Reference
Dim constraint1 As Constraint
Dim ConString As String

For i = 1 To n
    ConString = ""
    ConString = "Product_From_Part_" & prt & "/" & BodyName(i) & ".1/!" & "Product_From_Part_" & prt & "/" & BodyName(i) & ".1/"
    arrayOfVariantOfBSTR1(0) = Left(name, Len(name) - Len(partDocument1.name)) & BodyName(i) & ".CATPart"
    Set products1Variant = products1
    StrConstrain = "Product_From_Part_" & Left(partDocument1.name, Len(partDocument1.name) - 8) & "/" & Left(partDocument1.name, Len(partDocument1.name) - 8) & "_PartBody.1/!" & "Product_From_Part_" & Left(partDocument1.name, Len(partDocument1.name) - 8) & "/" & Left(partDocument1.name, Len(partDocument1.name) - 8) & "_PartBody.1/"
    products1Variant.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All"
    Set reference1 = product1.CreateReferenceFromName(ConString)
    Set constraint1 = constraints1.AddMonoEltCst(catCstTypeReference, reference1)
Next 'i

End Sub

Regards
Fernando

 
Fernando,

We had a need to convert some old multi-body CATPart files into a CATProduct and we came across this thread with the script you provided. It worked great! Saved us a lot of time and headaches. Thanks for posting the code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top