VB : Inventor API Exports with wrong scale

VB : Inventor API Exports with wrong scale

floyd.schramm
Explorer Explorer
550 Views
2 Replies
Message 1 of 3

VB : Inventor API Exports with wrong scale

floyd.schramm
Explorer
Explorer

So I am working on a Project to export an .ipt as any CAD file with one key press. I got it working but whenever I export to an .stl the scale is wrong. Its exports like option "Units" is set to cm and not mm.

This is my implementation :

Imports InventorDim 
ThisApplication
As Inventor.Application

In the Start Sub :

InitializeComponent()

Try    
ThisApplication
= Marshal.GetActiveObject("Inventor.Application") Catch ex As Exception MsgBox(ex.ToString())
MsgBox
("Unable to get Inventor") End Try

This is the code is used to open the Export window :

Dim Commander As CommandManager
Commander = ThisApplication.CommandManager
Dim Controler As ControlDefinition Controler = Commander.ControlDefinitions.Item("AppFileExportCADFormatCmd") Call Controler.Execute()

But whenever the export window is opened via my program the export scale is wrong but when I open the window manually everything is fine. Is there something to add to the API call to get the desired scale?

0 Likes
551 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant

Hi @floyd.schramm

 

Welcome to the forum. Here is an iLogic STL export example that might help.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oApp = ThisApplication
Dim oDoc As Document = ThisDoc.Document
Dim oSTL As TranslatorAddIn
oSTL = oApp.ApplicationAddIns.ItemById("{81CA7D27-2DBE-4058-8188-9136F85FC859}")
Dim oContext As TranslationContext
oContext = oApp.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oOptions As NameValueMap
oOptions = oApp.TransientObjects.CreateNameValueMap

' Create a DataMedium object
Dim oDataMedium As DataMedium
oDataMedium = oApp.TransientObjects.CreateDataMedium

If oSTL.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
	oOptions.Value("OutputFileType") = 0 '0 = Binary , 1 = ASCII
	oOptions.Value("ExportUnits") = 5 'IN = 2, FT = 3, CM = 4, MM = 5
	oOptions.Value("Resolution") = 0  'HIGH = 0, MEDIUM = 1, LOW = 2
	oOptions.Value("ExportColor") = True
End If

'Set the destination file name
oPath = "C:\TEMP\Export Folder\"
oName = ThisDoc.FileName(False) 'without extension
oDataMedium.FileName = oPath & oName & ".stl"

'write out file.
Call oSTL.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium)

EESignature

0 Likes
Message 3 of 3

floyd.schramm
Explorer
Explorer

This is not really what I searched for but it will definitely do! 

Thanks a lot! Smiley Happy

0 Likes