Create an assembly document C#

Top  Previous  Next

This code creates a new assembly and sets the measurement units to be mm

 

       public static AssemblyDocument CreateNewAssembly ()

       {

           try

           {

               // Get the list of documents currently open inventor

               Documents DocList = m_Inventor.Documents;

 

               FileManager FileMan = m_Inventor.FileManager;

 

               string sTemplateFile = FileMan.GetTemplateFile(DocumentTypeEnum.kAssemblyDocumentObject,

                                                              SystemOfMeasureEnum.kMetricSystemOfMeasure); // Make sure metric units

 

               // Create the doc and get hold of it...

               AssemblyDocument NewAsmDoc = (AssemblyDocument)DocList.Add(DocumentTypeEnum.kAssemblyDocumentObject);

               NewAsmDoc.UnitsOfMeasure.LengthUnits = UnitsTypeEnum.kMillimeterLengthUnits; // make sure mm units

 

               return NewAsmDoc;

           }

 

           catch (Exception Ex)

           {

               MessageBox.Show("Create new assembly failed, " + Ex.Message);

               return null;

           }

       }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Enter topic text here.

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)