Setting up export parameters for .obj .stp and .dwg in Ilogic

Setting up export parameters for .obj .stp and .dwg in Ilogic

peterd123
Participant Participant
8,584 Views
4 Replies
Message 1 of 5

Setting up export parameters for .obj .stp and .dwg in Ilogic

peterd123
Participant
Participant

I am currently using this code to export from Ilogic

ThisDoc.Document.SaveAs(ThisDoc.Path + file_directory + file_name + ".dwg", True) 
ThisDoc.Document.SaveAs(ThisDoc.Path + file_directory + file_name + ".obj", True) 
ThisDoc.Document.SaveAs(ThisDoc.Path + file_directory + file_name + ".stp", True)

What I can not do is adjust the quality settings.  When I first starting using this it was .obj files were about 300k.  Now they are about 2500k.

For the dwg, I would like to specify which version to save it under, and I am wondering if it is possible to set each part to seperate layers.  Right now everything is on layer 0.

0 Likes
8,585 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

If you want to be able to set options when you export the files, you will have to use a different routine other than a simple SaveAs().  The two most popular alternatives for exporting files to different file types,  while specifying options are:

1) Accessing and using Inventor's built-in Translator Add-in for each of those three types of documents, then using their available methods to set your options and export.  This is the longer route, but it is most likely much better documented, and might be the only route that will allow specifying the options you want for for all three file formats.

Available Sample Codes:  Export to STEP API Sample ; Save as STEP Translator Sample API Sample ; Save as DWG Translator Sample API Sample ; Export to DWG API Sample (Unfortunately, these samples are all in VBA, not iLogic)

 

2) Using DataIO object of the document's ComponentDefinition, and its' 'WriteDataToFile' method.  This route is less documented, and includes a single (usually very long) 'format' String, that contains all option names and their values.  However, these available options are only shown for exporting Sheet Metal parts out to DXF files.  Determining and implementing all the available options for "Obj" and "Stp" files may be quite challenging, if there aren't any existing user posted examples of them.

Available Sample codes:  Translate - Sheet Metal to DXF API Sample 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you have time, please... Vote For My IDEAS 💡or you can Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

peterd123
Participant
Participant

I was afraid that it wouldnt be that simple.  Time to figure out VBA for Inventor.

I have tried to look into the options available for the dwg export, but cant find anything explaining it.

Any suggestions on where to look for this?

I would also want to set up that different parts of an assembly be mapped to different layers.  Any ideas on this?

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

Don't give up hope on iLogic yet.  Most things that can be done through VBA can also be done using Inventor's iLogic (which uses VB.NET), they just use slightly different code variations, both based on Visual Basic. 

There are ways to get which options are exposed/available when working with Inventor's Translator Add-ins.  They can be used through either VBA or iLogic (or even other programming languages).

Here is an iLogic rule I wrote at some point that will create a new text file, and write out all available info about each of Inventor's translator add-ins, and what options they have available.  It also writes whatever the default or current values for those options are too.  Usually when you see either the Value of 0 (zero) or 1 (one), it means 0 = False and 1 = True, instead of using the terms "True" or "False" directly.

I have some lines commented out, because they were either annoying or troublesome for some reason.

And the end of the code, I chose to comment out the lines (for reference) where it would normally save and close that text document, then relaunch it to show you the result.  This way it simply stays open.

Here it that iLogic rule:

Sub Main
	'Text file FullFileName (with path & extension)
	'where you want it to create the new text file to write this into
	oTxtFileName = "C:\Temp\Translator Add-In Options.txt"
	oWrite = System.IO.File.CreateText(oTxtFileName)
	
	Dim oTO As TransientObjects = ThisApplication.TransientObjects
	Dim oSourceObject As Object = ThisApplication.ActiveDocument
	Dim oContext As TranslationContext = oTO.CreateTranslationContext
	oContext.Type = IOMechanismEnum.kDataDropIOMechanism
	Dim oOptions As NameValueMap = oTO.CreateNameValueMap

	Dim oAddIns As ApplicationAddIns = ThisApplication.ApplicationAddIns
	For Each oAddIn As ApplicationAddIn In oAddIns
		If oAddIn.AddInType = ApplicationAddInTypeEnum.kTranslationApplicationAddIn Then
			Dim oTransAddIn As TranslatorAddIn = oAddIn
			oTransAddIn.Activate
			' Check if the translator has 'SaveCopyAs' options
			Try
				If oTransAddIn.HasSaveCopyAsOptions(oSourceObject, oContext, oOptions) = True Then
					oWrite.WriteLine("")
					oWrite.WriteLine("")
					oWrite.WriteLine("Translator AddIn Information:")
					oWrite.WriteLine("DisplayName = " & oTransAddIn.DisplayName)
					oWrite.WriteLine("ShortDisplayName = " & oTransAddIn.ShortDisplayName)
					oWrite.WriteLine("Description = " & oTransAddIn.Description)
	'				oWrite.WriteLine("ClassIdString = " & oTransAddIn.ClassIdString)
	'				oWrite.WriteLine("ClientId = " & oTransAddIn.ClientId)
	'				oWrite.WriteLine("DataVersion = " & oTransAddIn.DataVersion)
	'				oWrite.WriteLine("Hidden = " & oTransAddIn.Hidden.ToString)
	'				oWrite.WriteLine("LicenseStatus = " & oTransAddIn.LicenseStatus.ToString)
					oWrite.WriteLine("LoadAutomatically = " & oTransAddIn.LoadAutomatically)
					If oTransAddIn.LoadAutomatically = True Then
						oWrite.WriteLine("LoadBehavior (load time) = " & oTransAddIn.LoadBehavior.ToString)
					End If
					oWrite.WriteLine("DLL FullFileName = " & oTransAddIn.Location)
		'			oWrite.WriteLine("ProgId = " & oTransAddIn.ProgId)
	'				oWrite.WriteLine("UserInterfaceVersion = " & oTransAddIn.UserInterfaceVersion.ToString)
	'				oWrite.WriteLine("UserUnloadable = " & oTransAddIn.UserUnloadable.ToString)
					oWrite.WriteLine("")
					oWrite.WriteLine("Options:  (Name & = & Value)")
					For i As Integer = 1 To oOptions.Count - 1
						oWrite.WriteLine(oOptions.Name(i) & " = " & oOptions.Value(oOptions.Name(i)))
					Next
				Else
					MsgBox("The TranslatorAddIn Named '" & oTransAddIn.DisplayName & "' doesn't have SaveCopyAs Options.",,"")
				End If
			Catch
				'MsgBox("Failed to write out information about a Translator Add-in.",,"")
			End Try
		Else
			'MsgBox("The AddIn named " & oAddIn.DisplayName & " was not a Translation AddIn.",,"")
		End If
	Next
'	oWrite.Close
	'open the file
'	ThisDoc.Launch(oTxtFileName)
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you have time, please... Vote For My IDEAS 💡or you can Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor

Hi @peterd123.

Just dropping a link here to another related forum post I just worked on, in which I provide a full working (I think) example of the OBJ export translator in iLogic code, with all of its current available options specified, just in case it may help you also.

https://forums.autodesk.com/t5/inventor-customization/fixing-quot-high-quot-resolution-export-option... 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes