How to pass the transformation matrix to imported component inside part environment using c#

How to pass the transformation matrix to imported component inside part environment using c#

sneha.sadaphal
Advocate Advocate
514 Views
3 Replies
Message 1 of 4

How to pass the transformation matrix to imported component inside part environment using c#

sneha.sadaphal
Advocate
Advocate

Hi,

I am loading the step file as a imported component in part environment by using c# API 

But I want to rotate the part from Y up to Z up direction (Mentioned in attached images)

snehasadaphal_0-1690432315720.png

snehasadaphal_1-1690432357893.png

Can anybody have the solution for this?

here is the code snap for above 

 PartDocument pDoc = _pDoc as PartDocument;
                PartComponentDefinition oPartCompDef = pDoc.ComponentDefinition;
                ImportedGenericComponentDefinition impPart = (ImportedGenericComponentDefinition)oPartCompDef.ReferenceComponents.ImportedComponents.CreateDefinition(stepdownload);
                impPart.ReferenceModel = true;
                impPart.IncludeAll();

                oPartCompDef.ReferenceComponents.ImportedComponents.Add((ImportedComponentDefinition)impPart);


 

0 Likes
Accepted solutions (1)
515 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor
Accepted solution

You can use MoveFeature after import or add this imported component to the assembly with appropriate orientation.

 

Dim part As PartDocument = ThisDoc.Document

Dim bodies As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection(part.ComponentDefinition.SurfaceBodies)
Dim moveDef As MoveDefinition = part.ComponentDefinition.Features.MoveFeatures.CreateMoveDefinition(bodies)
Dim rotation = moveDef.AddRotateAboutAxis(part.ComponentDefinition.WorkAxes(1), True, Math.PI / 2)

part.ComponentDefinition.Features.MoveFeatures.Add(moveDef)

 

0 Likes
Message 3 of 4

sneha.sadaphal
Advocate
Advocate

Is there only this way to do in part environment?
because it will add one move feature in tree structure and also might be origin also will get change.

0 Likes
Message 4 of 4

Michael.Navara
Advisor
Advisor

If you don't want to modify the part, you can just re-orient the ViewCube and default views Top, default Isometric, etc.

0 Likes