DWG Export INI

DWG Export INI

Anonymous
Not applicable
1,681 Views
10 Replies
Message 1 of 11

DWG Export INI

Anonymous
Not applicable
I have used this routine since R7 and got most of the original code directly from Brian Ekins. Now in R8 something seem amiss. No matter what I do Inventor wants to use the ini file in Docs & Settings\Local Settings\Temp. I have tried running from both inside as a macro as well as externally in VB. Anyone have similar results or comments? Sub ExportToDwg() On Error Resume Next ' Get the Inventor Application Dim InvApp As Inventor.Application Set InvApp = ThisApplication ' Make sure a drawing document is open. If InvApp.ActiveDocumentType <> kDrawingDocumentObject Then MsgBox "A drawing document must be active." Exit Sub End If 'Get the translator addins Dim addIns As ApplicationAddIns Set addIns = InvApp.ApplicationAddIns 'Find the DWG Translator add-in Dim dwgAddIn As TranslatorAddIn Dim dxfAddIn As TranslatorAddIn Dim i As Long For i = 1 To addIns.Count If addIns(i).AddInType = kTranslationApplicationAddIn Then If addIns(i).Description = "Autodesk Internal DWG Translator" Then Set dwgAddIn = addIns.Item(i) End If End If Next i 'Activate AddIns dwgAddIn.Activate dxfAddIn.Activate Dim map As NameValueMap Dim context As TranslationContext Dim trans As TransientObjects Set trans = InvApp.TransientObjects Set map = trans.CreateNameValueMap Set context = trans.CreateTranslationContext context.Type = kFileBrowseIOMechanism Dim b As Boolean Dim file As DataMedium Set file = trans.CreateDataMedium 'Retrieve the export default ini files for dxf and dwg Dim dwgIni As String Err.Clear b = dwgAddIn.HasSaveCopyAsOptions(file, context, map) dwgIni = "C:\0\AlJon.ini" CmDlg.FileName = "" CmDlg.InitDir = "C:\Documents and Settings\tstrandberg\My Documents\Clients\Aljon - Avatech\AlJon" CmDlg.DialogTitle = "Avatech Inventor Utilities" ' Usage: Friendlyname1|*.ex1|Freindlyname2|*.ex2 etc. CmDlg.Filter = "AutoCAD Files(*.dwg)|*.dwg" CmDlg.ShowSave file.FileName = CmDlg.FileName If file.FileName = "" Then MsgBox "Operation cancelled.", vbExclamation, "Avatech Inventor Utilities" Exit Sub End If map.Value("Export_Acad_IniFile") = dwgIni dwgAddIn.SaveCopyAs InvApp.ActiveDocument, context, map, file MsgBox "Finished Processing", vbInformation, "Avatech Inventor Utilities" End Sub Tim Strandberg
0 Likes
1,682 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
Hey Tim,

Shouldn't dwgIni = "C:\0\AlJon.ini" be dwgIni = "C:\O\AlJon.ini"? Is the directory that the ini file is located a zero (0) or a capital "O"?

Also, I don't know if this would have anything to do with it but, have you created a new ini from R8? R8 added more linetype mapping than R7. Maybe its choking the old ini and reverting to the default ini.

Let us know if anything works.

Mike
0 Likes
Message 3 of 11

Anonymous
Not applicable
The foldername is a "zero". C:\0\AlJon.ini looks like this: [EXPORT SELECT OPTIONS] AUTOCAD VERSION=AutoCAD 2000 CREATE AUTOCAD MECHANICAL=No CREATE LAYER GROUP=No PARTS ONLY=No [EXPORT PROPERTIES] SELECTED PROPERTIES=DESCRIPTION,ITEM,PART NUMBER,QTY [EXPORT DESTINATION] SPACE=Model SCALING=Geometry MODEL GEOMETRY ONLY=No EXPLODE DIMENSIONS=No AUTOCAD TEMPLATE=C:\Documents and Settings\tstrandberg\My Documents\Clients\Aljon - Avatech\AlJon\templates\ACAD.dwg DESTINATION DXF=No [EXPORT DEFINE LAYERS] USE AUTOCADM LAYER NAMES=No Visible Edges=MyLayer Hidden Edges=Hid1 Tangent Edges=Tangent Edges Section View Lines=Section View Lines Detail Circle Lines=Detail Circle Lines Dimensions=MOJO Center Mark=Dim1 Symbols=Symbols Leader Lines=OBJ1 Sketch Lines=Sketch Lines Phantom Lines=Phantom Lines Symmetry Lines=Symmetry Lines Break Lines=Hid1 Chain Lines=Chain Lines Stitch 1 Lines=Stitch 1 Lines Stitch 2 Lines=Stitch 2 Lines Center Line=Cen1 Sketch Only Lines=Sketch Only Lines 07 Lines (Long)=07 Lines (Long) Bend Extents=Bend Extents Work Point=Work Point Work Axis=Work Axis Work Plane=Work Plane Hatch=Hatch Text=Text [EXPORT LINE TYPE & LINE SCALE] LINE TYPE FILE=C:\Program Files\Autodesk\Inventor 8\COMPATIBILITY\Support\invANSI.lin Continuous=Continuous;0. Dashed=DASHED;0. Dashed Space=DASHED_SPACE;0. Long Dash Dotted=LONG_DASH_DOTTED;0. Long Dash Double Dot=LONG_DASH_DOUBLE_DOT;0. Long Dash Triple Dot=LONG_DASH_TRIPLE_DOT;0. Dotted=DOTTED;0. Chain=CHAIN;0. Double Dash Chain=DOUBLE_DASH_CHAIN;0. Dash Double Dot=DASH_DOUBLE_DOT;0. Dash Dot=DASH_DOT;0. Double Dash Dot=DOUBLE_DASH_DOT;0. Double Dash Double Dot=DOUBLE_DASH_DOUBLE_DOT;0. Dash Triple Dot=DASH_TRIPLE_DOT;0. Double Dash Triple Dot=DOUBLE_DASH_TRIPLE_DOT;0. The ini it seems to be using is C:\Documents and Settings\tstrandberg\Local Settings\Temp\exportdwg80.ini and looks like this: [EXPORT SELECT OPTIONS] AUTOCAD VERSION=AutoCAD 2004 CREATE AUTOCAD MECHANICAL=No CREATE LAYER GROUP=No PARTS ONLY=No [EXPORT PROPERTIES] SELECTED PROPERTIES=ID,PART #,QTY,RTE,TITLE [EXPORT DESTINATION] SPACE=Model SCALING=Geometry MODEL GEOMETRY ONLY=No EXPLODE DIMENSIONS=No AUTOCAD TEMPLATE=C:\Documents and Settings\tstrandberg\My Documents\Clients\Aljon - Avatech\AlJon\templates\ACAD.dwg DESTINATION DXF=No [EXPORT DEFINE LAYERS] USE AUTOCADM LAYER NAMES=No Visible Edges=MOJO Hidden Edges=HID1 Tangent Edges=Tangent Edges Bend Extents=Bend Extents Section View Lines=Section View Lines Detail Circle Lines=Detail Circle Lines Dimensions=DIM1 Center Mark=Center Mark Center Line=CEN1 Symbols=ABLOCK Leader Lines=DIM1 Sketch Lines=Sketch Lines Break Lines=Break Lines Chain Lines=Chain Lines Phantom Lines=Phantom Lines Stitch 1 Lines=Stitch 1 Lines Stitch 2 Lines=Stitch 2 Lines Symmetry Lines=Symmetry Lines 07 Lines (Long)=07 Lines (Long) Sketch Only Lines=Sketch Only Lines Work Point=Work Point Work Axis=Work Axis Work Plane=Work Plane Hatch=Hatch Text=TXT1 [EXPORT LINE TYPE & LINE SCALE] LINE TYPE FILE=C:\PROGRA~1\Autodesk\INVENT~2\COMPATIBILITY\Support\invANSI.lin "MDB" wrote in message news:15446753.1095338493586.JavaMail.jive@jiveforum1.autodesk.com... > Hey Tim, > > Shouldn't dwgIni = "C:\0\AlJon.ini" be dwgIni = "C:\O\AlJon.ini"? Is the directory that the ini file is located a zero (0) or a capital "O"? > > Also, I don't know if this would have anything to do with it but, have you created a new ini from R8? R8 added more linetype mapping than R7. Maybe its choking the old ini and reverting to the default ini. > > Let us know if anything works. > > Mike
0 Likes
Message 4 of 11

Anonymous
Not applicable
tim,

Try deleting or renaming the ini file in the ...Documents and settings directory.

And...

Then change your code to this below just to see if it works like it should. I'm wondering if focus is being lost when the save dlg box is opened.


Dim dwgIni As String

Err.Clear
b = dwgAddIn.HasSaveCopyAsOptions(file, context, map)
dwgIni = "C:\0\AlJon.ini"

'CmDlg.FileName = ""
'CmDlg.InitDir = "C:\Documents and Settings\tstrandberg\My
'Documents\Clients\Aljon - Avatech\AlJon"
'CmDlg.DialogTitle = "Avatech Inventor Utilities"
' Usage: Friendlyname1|*.ex1|Freindlyname2|*.ex2 etc.
'CmDlg.Filter = "AutoCAD Files(*.dwg)|*.dwg"
'CmDlg.ShowSave

'file.FileName = CmDlg.FileName
file.FileName = "C:\0\test.dwg"
If file.FileName = "" Then
MsgBox "Operation cancelled.", vbExclamation, "Avatech Inventor
Utilities"
Exit Sub
End If
map.Value("Export_Acad_IniFile") = dwgIni
dwgAddIn.SaveCopyAs InvApp.ActiveDocument, context, map, file

Just shooing in the dark,
Mike
0 Likes
Message 5 of 11

Anonymous
Not applicable
When I rename or delete the ini in Local Settings, all geometry comes in on layer "0", so I'm assuming the ini is not being read. I will try your suggestion of removing the common dialog bit. "MDB" wrote in message news:5707437.1095444610375.JavaMail.jive@jiveforum1.autodesk.com... > tim, > > Try deleting or renaming the ini file in the ...Documents and settings directory. > > And... > > Then change your code to this below just to see if it works like it should. I'm wondering if focus is being lost when the save dlg box is opened. > > > Dim dwgIni As String > > Err.Clear > b = dwgAddIn.HasSaveCopyAsOptions(file, context, map) > dwgIni = "C:\0\AlJon.ini" > > 'CmDlg.FileName = "" > 'CmDlg.InitDir = "C:\Documents and Settings\tstrandberg\My > 'Documents\Clients\Aljon - Avatech\AlJon" > 'CmDlg.DialogTitle = "Avatech Inventor Utilities" > ' Usage: Friendlyname1|*.ex1|Freindlyname2|*.ex2 etc. > 'CmDlg.Filter = "AutoCAD Files(*.dwg)|*.dwg" > 'CmDlg.ShowSave > > 'file.FileName = CmDlg.FileName > file.FileName = "C:\0\test.dwg" > If file.FileName = "" Then > MsgBox "Operation cancelled.", vbExclamation, "Avatech Inventor > Utilities" > Exit Sub > End If > map.Value("Export_Acad_IniFile") = dwgIni > dwgAddIn.SaveCopyAs InvApp.ActiveDocument, context, map, file > > Just shooing in the dark, > Mike
0 Likes
Message 6 of 11

Anonymous
Not applicable
Brian? Kent? Charles? "MDB" wrote in message news:5707437.1095444610375.JavaMail.jive@jiveforum1.autodesk.com... > tim, > > Try deleting or renaming the ini file in the ...Documents and settings directory. > > And... > > Then change your code to this below just to see if it works like it should. I'm wondering if focus is being lost when the save dlg box is opened. > > > Dim dwgIni As String > > Err.Clear > b = dwgAddIn.HasSaveCopyAsOptions(file, context, map) > dwgIni = "C:\0\AlJon.ini" > > 'CmDlg.FileName = "" > 'CmDlg.InitDir = "C:\Documents and Settings\tstrandberg\My > 'Documents\Clients\Aljon - Avatech\AlJon" > 'CmDlg.DialogTitle = "Avatech Inventor Utilities" > ' Usage: Friendlyname1|*.ex1|Freindlyname2|*.ex2 etc. > 'CmDlg.Filter = "AutoCAD Files(*.dwg)|*.dwg" > 'CmDlg.ShowSave > > 'file.FileName = CmDlg.FileName > file.FileName = "C:\0\test.dwg" > If file.FileName = "" Then > MsgBox "Operation cancelled.", vbExclamation, "Avatech Inventor > Utilities" > Exit Sub > End If > map.Value("Export_Acad_IniFile") = dwgIni > dwgAddIn.SaveCopyAs InvApp.ActiveDocument, context, map, file > > Just shooing in the dark, > Mike
0 Likes
Message 7 of 11

Anonymous
Not applicable
Sorry Tim I really haven't done much work in this area. Not sure what might be going wrong. -- Kent Keller Autodesk Discussion Forum Facilitator "Tim Strandberg" wrote in message news:414e3f93_1@newsprd01... > Brian? Kent? Charles?
0 Likes
Message 8 of 11

Anonymous
Not applicable
Tim,

Try the attached program and let me know if it works.

the code used is basically the same as yours. the path to the ini file is hardcoded, so it should use the file "C:\0\AlJon.ini". Just make sure you have an idw open when you run it.

Mike
0 Likes
Message 9 of 11

Anonymous
Not applicable
Gallant try Mike but not dice. Did it work on you box? "MDB" wrote in message news:2296863.1095701913305.JavaMail.jive@jiveforum1.autodesk.com... > Tim, > > Try the attached program and let me know if it works. > > the code used is basically the same as yours. the path to the ini file is hardcoded, so it should use the file "C:\0\AlJon.ini". > > Mike
0 Likes
Message 10 of 11

Anonymous
Not applicable
Hmmm, it works perfectly on my end. Can you email me the files (ini, model and idw) to test on my end?

Mike
mbest@DUMPTHIStateornamental.com
0 Likes
Message 11 of 11

Anonymous
Not applicable
Hello,

We use Inventor 8 SP1 and i set up an INI file to export to DWG.

My question about this is:

Can you set the linetypes to export not to a linetype, but to BYLAYER?

That would save us yet another step in the conversion process.

Regards SBuurma
0 Likes