Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Please help me to modify my code. What I need is to change the rotation value not only one time.
I saw a code on youtube and I tried to modified it according to my needs.
here is my code snippet.
public void SetRotation(Document document, ModelItemEnumerableCollection modelItems, Rotation rotation, string modelPath)
{
foreach (var item in modelItems)
{
var loc = item.BoundingBox().Center;
var mb = new Vector3D(loc.X, loc.Y, loc.Z);
var mo = new Vector3D(-loc.X, -loc.Y, -loc.Z);
var transVec = Transform3D.CreateTranslation(mo);
Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentTransform(new List<ModelItem> { item }, transVec, true);
var rt = new Rotation3D(new UnitVector3D(rotation.x, rotation.y, rotation.z), (((rotation.angle) * (Math.PI / 180)) / 2));
var tr = new Transform3D(rt, mb);
Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentTransform(new List<ModelItem> { item }, new Transform3D(tr), true);
}
}
this works only one time when I run or click again my plugin the result is wrong.
because maybe there are wrong in the computation or matrix.
Thank you!
Solved! Go to Solution.