Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Translator addin - Importing DWG files without updating view

1 REPLY 1
Reply
Message 1 of 2
bjorn.egil.jenssen
302 Views, 1 Reply

Translator addin - Importing DWG files without updating view

Hi, I've created a translator addin for Inventor that converts multiple DWG files into Inventor Part files. However, I've noticed that for each file converted, Inventor will create a view and display the newly created Part file in the view. This is not optimal, as it is an unnecessary slowdown to have to render the graphics for each DWG file converted. I want to convert all my files without anything beeing displayed, as this will be both faster, and possibly more stable (I will potentially convert several thousand files in one run). The following code line will display the graphics: oAddin.Open(dm, context, nvm, out oNewDoc); <-- this line updates the inventor view If I replace the TranslatorAddin with for example the SAT importer, no such view is created. Everything works in the background with nothing rendered the view. This is the functionality I want to achieve with the DWG importer. Below is the source code for the import method. Anyone have an idea on how to accomplish converting DWG files without the graphics showing? public static void ImportDWGFromFileAsSolid(string fileName) { // DWG importer Inventor.TranslatorAddIn oAddin = (Inventor.TranslatorAddIn)m_inventorApplication.ApplicationAddIns.get_ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}"); // create context for open TransientObjects oTransObjs = m_inventorApplication.TransientObjects; TranslationContext context = oTransObjs.CreateTranslationContext(); context.Type = IOMechanismEnum.kFileBrowseIOMechanism; // create open option NameValueMap nvm = m_inventorApplication.TransientObjects.CreateNameValueMap(); // create data medium DataMedium dm = oTransObjs.CreateDataMedium(); dm.FileName = fileName; // set dwg_config.ini location string strIniFile = assemblyFolder + "\\" + "dwg_config.ini"; if (!System.IO.File.Exists(strIniFile)) Debug.Print("Error ini file not found"); nvm.set_Value("Import_Acad_IniFile", strIniFile); // import the DWG file object oNewDoc = null; oAddin.Open(dm, context, nvm, out oNewDoc); Document new_doc = (Document)oNewDoc; // process, save and close the part file } Below is the content of the dwg_config.ini. Is there any of these options that might disable the graphics showing? [COMMON OPTIONS] FILE VERSION=3.0 IMPORT FILE TYPE=AutoCAD DWG File FILE UNITS=Millimeters SELECTED LAYOUT=Model IMPORT LAYOUTS=No IMPORT MODEL SPACE=Yes DRAWING TEMPLATE=Standard.idw SHEET SIZE=Custom Millimeters PART TEMPLATE=Standard.ipt ASSEMBLY TEMPLATE=Standard.iam [2D OPTIONS] DESTINATION 2D DATA=New Part IMPORT TO 3D SKETCHES=Yes CREATE IFO=No IMPORT 3D SOLIDS=Yes IMPORT 3D SOLIDS TO SINGLE PART FILE=Yes CONSTRAIN ENDPOINTS (SKETCH)=No CONSTRAIN ENDPOINTS (DRAWING)=No CONSTRAIN LOGICAL (SKETCH)=No CONSTRAIN LOGICAL (DRAWING)=No DETECT FROM FILE=Yes USE DEFAULT NAMES=Yes PROMOTE DRAWING DIMENSIONS=No PROXY OBJECTS TO USER DEFINED SYMBOLS=No CREATE SKETCH BLOCKS=No IMPORT GEOMETRIC CONSTRAINTS=No LAYERS OFF= LAYERS ON=0 IMPORT SURFACES=Yes IMPORT WIRES=Yes [IMPORT MAP LAYER TO SKETCH] MAP ALL LAYERS TO SINGLE SKETCH=No [IMPORT MAP ACAD FONT TO IVT FONT] [3D OPTIONS] TRANSLATE MODEL=Yes TRANSLATE DRAWING VIEWS=No PART MODE=Translate Feature Recipe FEATURE RECIPE MODE=Translate Recipe If All Features Supported COMPDEF MODE=Translate Instanced CompDefs Only DRAWING MODE=Unassociated Drawing Views DUPLICATE FILE ACTION=Overwrite Existing File SUPPRESS SINGLE PART ASSEMBLY=Yes SYMBOL MODE=Translate Mechanical Symbols to Single Sketch
1 REPLY 1
Message 2 of 2

For some reason all newlines disapeared! Didnt find an edit button, so here is the post again.... --- Hi, I've created a translator addin for Inventor that converts multiple DWG files into Inventor Part files. However, I've noticed that for each file converted, Inventor will create a view and display the newly created Part file in the view. This is not optimal, as it is an unnecessary slowdown to have to render the graphics for each DWG file converted. I want to convert all my files without anything beeing displayed, as this will be both faster, and possibly more stable (I will potentially convert several thousand files in one run). The following code line will display the graphics: oAddin.Open(dm, context, nvm, out oNewDoc); <-- this line updates the inventor view If I replace the TranslatorAddin with for example the SAT importer, no such view is created. Everything works in the background with nothing rendered the view. This is the functionality I want to achieve with the DWG importer. Below is the source code for the import method. Anyone have an idea on how to accomplish converting DWG files without the graphics showing? public static void ImportDWGFromFileAsSolid(string fileName) { // DWG importer Inventor.TranslatorAddIn oAddin = (Inventor.TranslatorAddIn)m_inventorApplication.Ap​plicationAddIns.get_ItemById("{C24E3AC2-122E-11D5-​8E91-0010B541CD80}"); // create context for open TransientObjects oTransObjs = m_inventorApplication.TransientObjects; TranslationContext context = oTransObjs.CreateTranslationContext(); context.Type = IOMechanismEnum.kFileBrowseIOMechanism; // create open option NameValueMap nvm = m_inventorApplication.TransientObjects.CreateNameV​alueMap(); // create data medium DataMedium dm = oTransObjs.CreateDataMedium(); dm.FileName = fileName; // set dwg_config.ini location string strIniFile = assemblyFolder + "\\" + "dwg_config.ini"; if (!System.IO.File.Exists(strIniFile)) Debug.Print("Error ini file not found"); nvm.set_Value("Import_Acad_IniFile", strIniFile); // import the DWG file object oNewDoc = null; oAddin.Open(dm, context, nvm, out oNewDoc); Document new_doc = (Document)oNewDoc; // process, save and close the part file } Below is the content of the dwg_config.ini. Is there any of these options that might disable the graphics showing? [COMMON OPTIONS] FILE VERSION=3.0 IMPORT FILE TYPE=AutoCAD DWG File FILE UNITS=Millimeters SELECTED LAYOUT=Model IMPORT LAYOUTS=No IMPORT MODEL SPACE=Yes DRAWING TEMPLATE=Standard.idw SHEET SIZE=Custom Millimeters PART TEMPLATE=Standard.ipt ASSEMBLY TEMPLATE=Standard.iam [2D OPTIONS] DESTINATION 2D DATA=New Part IMPORT TO 3D SKETCHES=Yes CREATE IFO=No IMPORT 3D SOLIDS=Yes IMPORT 3D SOLIDS TO SINGLE PART FILE=Yes CONSTRAIN ENDPOINTS (SKETCH)=No CONSTRAIN ENDPOINTS (DRAWING)=No CONSTRAIN LOGICAL (SKETCH)=No CONSTRAIN LOGICAL (DRAWING)=No DETECT FROM FILE=Yes USE DEFAULT NAMES=Yes PROMOTE DRAWING DIMENSIONS=No PROXY OBJECTS TO USER DEFINED SYMBOLS=No CREATE SKETCH BLOCKS=No IMPORT GEOMETRIC CONSTRAINTS=No LAYERS OFF= LAYERS ON=0 IMPORT SURFACES=Yes IMPORT WIRES=Yes [IMPORT MAP LAYER TO SKETCH] MAP ALL LAYERS TO SINGLE SKETCH=No [IMPORT MAP ACAD FONT TO IVT FONT] [3D OPTIONS] TRANSLATE MODEL=Yes TRANSLATE DRAWING VIEWS=No PART MODE=Translate Feature Recipe FEATURE RECIPE MODE=Translate Recipe If All Features Supported COMPDEF MODE=Translate Instanced CompDefs Only DRAWING MODE=Unassociated Drawing Views DUPLICATE FILE ACTION=Overwrite Existing File SUPPRESS SINGLE PART ASSEMBLY=Yes SYMBOL MODE=Translate Mechanical Symbols to Single Sketch

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

Post to forums  

Autodesk Design & Make Report