Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem in Scaling a rotated object

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
567 Views, 2 Replies

Problem in Scaling a rotated object

Hi,

 

I am doing naviswork automation through .NET.

I place a rectangle and rotate a rectangle to 30degree, the rotation towards Z Axis(0,0,0) and trying to scale towards X-Axis, the scale is not coming properly and shape of the object is getting change.

 

Following is my transformation matrix.

 

Rotation = {0.866025, 0.5, 0, 0, -.5, 0.866025, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}.

Scale = {2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}

 

Rotation is working fine.

 

i used to multiple Rotation * Scale

 

My result is {1.73205, 0.5, 0, 0, -1, 0.866025, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}

 

then i set this matrix to transform(eObjectType_nwLTransform3f) matrix.

 

Is there any other way to do scale a rotated object also please tell me.

 

I am very new to Naviswork as well as 3D.

 

Please help me.

2 REPLIES 2
Message 2 of 3
xiaodong_liang
in reply to: Anonymous

Hi,

 

I assume you are using COM API to transform the object, instead of the new API of .NET in 2014. I created a rectangle in a DWG and gave it a test with the following code. It firstly rotates and next scales. To make clearer, I spilt it to the two steps. The attachment is the DWG and the snapshots at my side. The result looks well to me.

 

If you are still having problem, please do isolate and provide more details, particually the code demo.

 

public override int Execute(params string[] parameters)
{
Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument;
ModelItemCollection oMC = oDoc.CurrentSelection.SelectedItems;

ComApi.InwOpState10 oState =ComApiBridge.ComApiBridge.State;
ComApi.InwOpSelection oSel =
ComApiBridge.ComApiBridge.ToInwOpSelection(oMC);

// create transform matrix
ComApi.InwLTransform3f3 oTrans1 =
(ComApi.InwLTransform3f3)oState.ObjectFactory
(ComApi.nwEObjectType.eObjectType_nwLTransform3f,
null, null);
// make rotation
ComApi.InwLRotation3f2 oRot = (ComApi.InwLRotation3f2)oState.ObjectFactory
(ComApi.nwEObjectType.eObjectType_nwLRotation3f,
null, null);

ComApi.InwLUnitVec3f oVec =
(ComApi.InwLUnitVec3f)oState.ObjectFactory
(ComApi.nwEObjectType.eObjectType_nwLUnitVec3f,
null, null);
oVec.SetValue(0, 0, 1);
oRot.SetValue(oVec,45);
oTrans1.MakeRotation(oRot);
// transform
oState.OverrideTransform(oSel, oTrans1);
ComApi.InwLTransform3f3 oTrans2 =
(ComApi.InwLTransform3f3)oState.ObjectFactory
(ComApi.nwEObjectType.eObjectType_nwLTransform3f,
null, null);
//make scale 
ComApi.InwLVec3f oScaleVec =
(ComApi.InwLVec3f)oState.ObjectFactory
(ComApi.nwEObjectType.eObjectType_nwLVec3f,
null, null);
oScaleVec.SetValue(2, 1, 1);
oTrans2.MakeScale(oScaleVec);
// transform
oState.OverrideTransform(oSel, oTrans2);
}

 

Message 3 of 3
Anonymous
in reply to: xiaodong_liang

Thanks for your reply. I am using COM API and Navisworks 2012. I used to multiply both the matrix(Rotation and Scale) to get solution, its working well.

Once again Thank you so much.


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report