Not able to save units as mm & DefaultTemplateDrawingStandard in fileoptions using API in C#

Not able to save units as mm & DefaultTemplateDrawingStandard in fileoptions using API in C#

Anonymous
Not applicable
391 Views
4 Replies
Message 1 of 5

Not able to save units as mm & DefaultTemplateDrawingStandard in fileoptions using API in C#

Anonymous
Not applicable

Hello API team,

 

I am able to set the required values to file options in Application options using API.

 

m_inventorApplication.FileOptions.DefaultTemplateUnitsAreInches = false;
m_inventorApplication.FileOptions.DefaultTemplateDrawingStandard =
Inventor.DraftingStandardEnum.kANSI_DraftingStandard;

 

The above changes are reflecting in Inventor tool but not able to see the units as mm in the assembly document as like in the attachment (pic-1 but expecting as like in pic-2 which in the same attachment.)

 

I tried to save the file options using the below code (it is replicating the clicking on "Ok" and "apply" button ApplicationOptions window) but get an error "Member not found".

m_inventorApplication.SaveOptions.DefaultToSaveForAPIChanges = true;
m_inventorApplication.SaveOptions.PromptSaveForAPIChanges = false;

 

Request your solution how to fix it.

Thanks in advance.

 

 

0 Likes
392 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor

I'm not sure but if I'm correct changing the settings does not update old drawings. They will keep using old units. For your test did you open an old model or did you make a new model?

 

If i change the settings manually i get this dialog.

JelteDeJong_0-1636556569057.png

Did you check your templates after setting the settings with the API?

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 5

WCrihfield
Mentor
Mentor

You said that the changes were reflecting in the Inventor Application itself, but then those units settings were not showing as expected in an assembly in your example images.  Was that assembly already open, or already existing when you made the changes to the application options?  Once a document has been created or already exists, if the Standard or Units are not the way you want them, then you will have to use the Document Settings instead of the Application Options, in order to change that document.  Those settings can all be set by code too if needed.

The document units can be get/set through these:

PartDocument.UnitsOfMeasure.LengthUnits

PartDocument.UnitsOfMeasure.AngleUnits

PartDocument.UnitsOfMeasure.TimeUnits

PartDocument.UnitsOfMeasure.MassUnits

There are also other settings accessible in the API for most of what you see in the Document Settings dialog.

 

I personally don't use one standard or default template for creating new documents.  I have multiple part templates, multiple assembly templates, and multiple drawing templates.  Within each one I have all the Document Settings the way I want them, and any other resources I may need in all new documents generated by that template.  Maybe create yourself a set of custom templates to start documents from (using New command), then set them up the way you want them individually.  Just a thought.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 5

Anonymous
Not applicable

Thank you for the reply, JelteDeJong.

 

I am testing with new models only. I too get the dialog which asks for Overwrite but the same thing , I am expecting using API without prompting for the dialog. This is the first step.

Another step is, I need to click on either "Ok" or "Apply" in the ApplicationOptions window otherwise model won't show in "mm".

Please let me know how can I achieve it using API.

Thank you.

 
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thank you for the reply, WCrihfield
The requirement is to have at application level so request you to share the code snippet how to save the file options if you are aware.
Thank you in advance.
0 Likes