ResetPermanentTransform

ResetPermanentTransform

m.shcheblykin
Contributor Contributor
978 Views
5 Replies
Message 1 of 6

ResetPermanentTransform

m.shcheblykin
Contributor
Contributor

Hello dear API professionals,

Could you advise what is wrong in my syntax.

I use a python shell. I have an NWC file in an opened NWF file.

This NWC file has some transformation: 

mshcheblykin_0-1663270559849.png

 

 

selection = doc.CurrentSelection.SelectedItems

//here I have 2 options how to write it. None of them gives me an error. But non of them reset transformation either.

doc.Models.ResetPermanentTransform(selection)

doc.Models.ResetPermanentTransform([ selection[0] ])

 

please advise the correct syntax to reset transformation back to zeros 

0 Likes
Accepted solutions (1)
979 Views
5 Replies
Replies (5)
Message 2 of 6

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @m.shcheblykin ,

 

What steps did you follow to achieve the functionality you want in Navisworks UI?

As far as I know, you can set Units and Transform values using the below code

DocumentModels models = doc.Models;
models.SetModelUnitsAndTransform();

I don't understand what you mean by Reset. In Units and Transform, there is no reset option even in the UI.

Please note, if the Navisworks UI does not support what you are trying to do, the API will probably not do so either.

So, it will always help to research the optimal manual approach to a solution first, before attacking the task programmatically.

I hope this explains.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 6

m.shcheblykin
Contributor
Contributor

Thank you for your reply.
What I am trying to do is to reset all transformation values back to original which are zeros.

Lets say I have nwc files that were moved and rotated previously and now I want to move and rotate them back.

I came to this idea coz I found that a method OverridePermanentTransform increments the given transformation values to current once.

example: if origin X = 100m, Y =  32.22m, Z = 4.65m

mshcheblykin_0-1663395889294.png

after OverridePermanentTransform method has been applied with values (100,100,100)

the result will be X = 200m, Y =  132.22m, Z = 104.65m

Because of this I have to reset all transformation values back to 0 and only after set new values that represent the updated location

 

The code is below:
selection = doc.CurrentSelection.SelectedItems

move =  Transform3D.CreateTranslation( Vector3D(100, 100, 100)) //Here should be values in feet but for simplicity I keep them in miters
doc.Models.OverridePermanentTransform([selection], Transform3D(move), True)

 

 

If there is a method which works not like increment and simply sets new values which are given, please tell me the name of it. In this case I will not need to play with a resetting step.

 

Could you ad advise what is wrong with the syntax bellow. Catching an error : Syntax Error: unexpected EOF while parsing (line 10)

 

doc.Models.SetModelUnitsAndTransform(selection[0],Units.Meters,Transform3D.CreateTranslation(Vector3D(0, 0, 0),False)

0 Likes
Message 4 of 6

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @m.shcheblykin ,

 

Please take a look at this sample code and the screenshots attached

 

DocumentModels models = doc.Models;
Model model = null;
foreach(Model m in models)
     {
       if(m!=null)
         {
           model = m;
           break;
         }
      }

Rotation3D rotation3D = new Rotation3D(new UnitVector3D(0, 0, 1), 0.872665);
Vector3D vector3D = new Vector3D(2, 3, 4);//Origin
Transform3D t3d = new Transform3D(rotation3D, vector3D);
models.SetModelUnitsAndTransform(model, Units.Meters, t3d, true);

 

 

Here 50 degree=0.872665 radian 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 6

m.shcheblykin
Contributor
Contributor

okay, I think I understood more or less navis api structure, at least that par which I need right now.

Looks like a navis APi forum is not really so active unlike forums for Revit and Dynamo.

All these API for me like jungles. There is no clear graphs or graphical tree structures to see how different APIs are arranged (Revit, Navis, Rhino3D). Always need to do numerous attempts with different things till I catch the right class for a certain method.  Can you advise any ways to study of API structures  ? 

I also found how to reset all transformed models back to 0 values:

doc.Models.SetModelUnitsAndTransform(doc.Models[0],Units.Feet,Transform3D.CreateIdentity(),False)

 

Thank you very much.

0 Likes
Message 6 of 6

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @m.shcheblykin ,

 

The "Reference Guide" section in the below link will help you to understand Navisworks API Structure(i.e)how different APIs are arranged in Navisworks.

https://apidocs.co/apps/navisworks/2018/N_Home.htm 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network