ilogic code to export dxf from Unwrap

ilogic code to export dxf from Unwrap

b.mccarthy
Collaborator Collaborator
991 Views
9 Replies
Message 1 of 10

ilogic code to export dxf from Unwrap

b.mccarthy
Collaborator
Collaborator

Hello.

 

There are many routines available to auto-generate a dxf from a flat pattern. Can the same be done for an Unwrap feature?

 

TIA

0 Likes
Accepted solutions (3)
992 Views
9 Replies
Replies (9)
Message 2 of 10

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Assuming:

- the Unwrap feature exist in the part file

- there is just one Unwrap feature

- the feature faces are merged to one face

 

    Dim oPartDoc As PartDocument=ThisDoc.Document
    Dim oUnwrap As UnwrapFeature = oPartDoc.ComponentDefinition.Features.UnwrapFeatures(1)
    Dim oFace As Object= oUnwrap.SurfaceBody.Faces(1)
    Dim oSelect As SelectSet= oPartDoc.SelectSet
    Dim sFilename As String = System.IO.Path.GetFileNameWithoutExtension(oPartDoc.FullFileName)
	Dim sPath As String = System.IO.Path.GetDirectoryName(oPartDoc.FullFileName)
	
	Call oSelect.Select(oUnwrap.SurfaceBody.Faces(1))
    
    If oSelect.Count > 0 Then
        Call ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, sPath & "\" & sFilename & ".dxf")
        Call ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand").Execute
    End If
    
    oSelect.Clear

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 10

b.mccarthy
Collaborator
Collaborator

Perfect. Thank you!

0 Likes
Message 4 of 10

b.mccarthy
Collaborator
Collaborator

Hello.

 

I recently upgraded to 2024, and this rule no longer generates a dxf. Any idea why?

0 Likes
Message 5 of 10

Curtis_Waguespack
Consultant
Consultant

Hi @b.mccarthy ,

 

I'm not sure what the issue you're seeing is, but I just ran a simple test part with Inventor 2024 ( build 153) and it worked as expected ( created the DXF of the unwrap surface).

 

Maybe it's something specific to your geometry?

 

See attached file for you to test/verify my results if you'd like.

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

EESignature

0 Likes
Message 6 of 10

b.mccarthy
Collaborator
Collaborator

Thank you for the response, Curtis. Additional information is in order...

 

I typically use the Unwrap tool to generate a dxf from a sheet metal part that cannot be unfolded, and requires additional fabrication. Not my preferred workflow, but these projects do come my way from time to time. Although the resulting dxf is an approximation, at best, the fabricator has been able to use it to create an acceptable part.

 

Currently, I can generate the dxf using my version or yours, in one of 2 ways:

  • RMB on the Unwrap feature
  • Manually run the rule

 

However, my preferred workflow is to set the rule to fire before save, as I do when generating a dxf from a sheet metal part that can be flattened. That worked in 2023, but does not work for this rule in 2024, at least, not on my system. So far all the other rules run fine.

 

I tested this on your part, and the dxf did not generate:

 

2023-04-25 665.jpg

 

I only tested this on a few events, but the result is the same.

 

Can you generate the dxf on your system using Triggers?

 

Thank you.

 

0 Likes
Message 7 of 10

Curtis_Waguespack
Consultant
Consultant

HI @b.mccarthy 

 

I see the same results as you when trying this on the Before Save event

 

I was able to verify that on the save event the rule is running, and that the surface is getting selected.

 

I suspect the "PostPriavateEvent" line is the issue, but I'm not sure what would have changed from 2023 to 2024 in this regard, or what the fix is.

 

 

 

 

EESignature

0 Likes
Message 8 of 10

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Oh, wait try this:

 

Call ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand").Execute2(True)

 

 

  

EESignature

0 Likes
Message 9 of 10

b.mccarthy
Collaborator
Collaborator

Success!!

 

What does this tell Inventor to do?

Message 10 of 10

Curtis_Waguespack
Consultant
Consultant
Accepted solution

It's about when the command is told to run ( before or after the message).  see link

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-1715970A-16DF-43E9-9C6D-2ED3336C5420

 

In this case because there isn't really a message because the DXF command is using the file name off the Inventor clipboard, rather than displaying an input message box/form, but somehow it makes a difference to 2024.

 

Autodesk likely fixed something that was broke, or broke something that was fixed in the way that this was working ???? 

 

 

 

 

EESignature