Changing DXF version on Sketch export via Ilogic

Changing DXF version on Sketch export via Ilogic

AdamAG99T
Advocate Advocate
961 Views
5 Replies
Message 1 of 6

Changing DXF version on Sketch export via Ilogic

AdamAG99T
Advocate
Advocate

I am attempting to write a rule that will export a specific sketch as a DXF, but I need the DXF to be a 2000 version not the current 2018 version. I have the following line of code working fine exporting the sketch as a 2018 version DXF but I cant seem to find what I need to replace "DXF" with to get a 2000 version DXF. 

oExportSketch.DataIO.WriteDataToFile("DXF", StringOutputFilename)

 

I have found variations of the following on these forums already but I have not been able to get them to work, am I possibly missing something with this?

oExportSketch.DataIO.WriteDataToFile("FLAT PATTERN DXF?AcadVersion=2000", StringOutputFilename)

 

I am currently using inventor 2019 professional.

0 Likes
Accepted solutions (1)
962 Views
5 Replies
Replies (5)
Message 2 of 6

dutt.thakar
Collaborator
Collaborator

@AdamAG99T 

 

Have a look at this link, it is also showing the DXF export to Acad 2000.

 

https://adndevblog.typepad.com/manufacturing/2012/05/exporting-flat-pattern-as-dwgdxf.html

 

See if it helps.

 

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 6

AdamAG99T
Advocate
Advocate

I have attempted the format shown in that link before and it gives me an error message and fails to export the file. I believe the issue is that I am attempting to export a sketch in the flat pattern and not the flat pattern itself, since I am trying to include some text and other lines to etch. 

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

Have you reviewed these links yet?

DataIO Object

Translate - Sheet Metal to DXF API Sample 

They contain a lot of info about all the available options you can use when exporting to DXF using the DataIO object.  However, the example is exporting a ComponentDefinition out to a DXF, not a sketch.

How have you defined "StringOutputFilename"?  Is this String type variable?  Have you given it a value like "C:\Temp\Sketch.dxf"?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Here is another method you can try.  I know this process will export the sketch out to a DXF file, but whether or not the resulting file is formatted to AutoCAD 2000 is another issue.  It uses the same command found within the right click menu when you select a PlanarSketch object in your model browser tree.  It just bypasses the dialog box.  One of the things in that dialog box, though, is the option to select an earlier version of AutoCAD you want the resulting file to be compatible with.  This is a similar situation to using the SaveAs() method, because it too bypasses the usual dialog boxes, where you would normally be able to click on the Options button and set your settings.  In theory, if you have already exported a DXF file the way you want this one to be, it should remember those settings the next time you attempt to export a DXF, and use those same settings.  Or if you have a saved XML file for these settings, that you usually use, that file may already be selected, by default, because that's how you did it the last time you exported a DXF.  It's not the most controlled and stable process, but it may work for your situation.

Here's the code I used to test it:

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
	MsgBox("A Part Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oSketch As PlanarSketch = oPDef.Sketches.Item(1)
Dim oFileName As String = "C:\Temp\Sketch.dxf"
Dim oSelSet As SelectSet = oPDoc.SelectSet
oSelSet.Clear
oSelSet.Select(oSketch)
ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oFileName)
ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand").Execute2(True)

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 6

AdamAG99T
Advocate
Advocate

I have already looked at the first link you posted and unfortunatly it doesnt seem to work nicely with exporting a sketch. StringOutputFilename was just a proper address like your example, and worked fine when I used the following line, just with the wrong version dxf.

oExportSketch.DataIO.WriteDataToFile("DXF", StringOutputFilename)

 

 Your 2nd solution seems to work fine, and since I only export as a 2000 version dxf anyways I believe it should be fine for the future.

0 Likes