Ilogic flat pattern

Ilogic flat pattern

Anonymous
Not applicable
4,179 Views
18 Replies
Message 1 of 19

Ilogic flat pattern

Anonymous
Not applicable

Is it possible to unfold a sheet metal part and save as a dwg in a specific folder automaticaly using ilogic?

0 Likes
4,180 Views
18 Replies
Replies (18)
Message 2 of 19

MjDeck
Autodesk
Autodesk

 I don't think so.  You're talking about the operation of right-clicking on a face in the flat pattern and choosing Export Face As... , right?

There is an API function available to do that for DXF export, but it looks like DWG is not available.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 3 of 19

Anonymous
Not applicable

yes thats what i was trying to do i guess dxf will be just as good. what would that function be?

0 Likes
Message 4 of 19

MjDeck
Autodesk
Autodesk

It's not actually a function.  You launch a command from the API, put it will complete automatically if you set it up with a filename.  Here's a function:

 

 Public Sub ExportBottomFaceToDxf(ByVal doc As Document, ByVal app As Inventor.Application)
  Dim partDoc As PartDocument = doc
  Dim sheetMetalDef As SheetMetalComponentDefinition = partDoc.ComponentDefinition
  If (Not sheetMetalDef.HasFlatPattern()) Then
   sheetMetalDef.Unfold()
  End If
  Dim flatPattern As FlatPattern = sheetMetalDef.FlatPattern

  flatPattern.Edit()

  Dim faceToExport As Face = GetBottomFace(flatPattern)

  If (faceToExport Is Nothing) Then
   MessageBox.Show("Can't get the bottom face of the flat pattern for the part: " & doc.DisplayName, "Export Flat Pattern as DXF")
  Else
   partDoc.SelectSet.Select(faceToExport)

   Dim filename As String = IO.Path.GetFileNameWithoutExtension(doc.FullFileName) + ".dxf"
   app.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, IO.Path.Combine(DxfOutputFolder, filename))

   Dim oCtrlDef As ControlDefinition
   oCtrlDef = app.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")

   oCtrlDef.Execute()
  End If

  flatPattern.ExitEdit()

 End Sub

 

This uses another function GetBottomFace to find the face to be exported.

 

The PostPrivateEvent call sets up the "GeomToDXFCommand" command with the filename for export.  Here I'm using a predefined variable  DxfOutputFolder.

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 19

Anonymous
Not applicable

From the help files --

 

DataIO Interface....

 

The sample code below writes a sheet metal file out as DXF.  DWG is also supported. Use either the FLAT PATTERN DWG or FLAT PATTERN DXF formats

0 Likes
Message 6 of 19

Anonymous
Not applicable

hmmm..so this has to be launched with a command from the APi? would it take the flat pattern from the part or from the drawing?

0 Likes
Message 7 of 19

MjDeck
Autodesk
Autodesk

The DataIO method posted by petercharles looks better than what I posted.  I'm not sure if it can export the bottom face, but it you want to export the top face the DataIO method looks good.

 

 Both methods would export the part.  Exporting a drawing would probably be easier.  But do you want to automatically:

1) unfold the flat pattern

2) create the drawing

3) export to DWG?

 

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 8 of 19

Anonymous
Not applicable

In my opinion automatically creating a flat pattern if one doesn't exist is dangerous.  If we don't preselect a face for the unfolding operation we frequently find the flat pattern is the "wrong hand".  (We use AIS 2010)

 

Many versions of IV ago I wrote an add-in to automatically create a flat pattern DXF when a sheet metal part was saved.  If a flat pattern did not exist one was created and it was ALWAYS the correct hand.  However between then and now something has changed and I don't trust automatic flat patterns any more!

0 Likes
Message 9 of 19

Anonymous
Not applicable

where did you find this int he help files? A sample code would be nice but i cant seem to find anything on this.

0 Likes
Message 10 of 19

Anonymous
Not applicable

Search for "DataIO" in the programming help file.

0 Likes
Message 11 of 19

Rene-J
Collaborator
Collaborator

Try this addin

 iFlatpatternExport Add-in

http://www.mcadforums.com/forums/viewtopic.php?f=34&t=11249

 

The addin can be set to export flatpattern on save.

If you only want to export with ilogic code,

you can put this command into your code. 

This will working if you have open a sheetmetal part or assembly 

 

Private Sub exportflatpattern()

Vba code
Dim oCtrlDef As ControlDefinition

  Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item

("autodesk:iflatpatternexport:iexpflatpatterncmdbtn")
      oCtrlDef.Execute

ilogic code

Dim oCtrlDef As ControlDefinition

 oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item

("autodesk:iflatpatternexport:iexpflatpatterncmdbtn")
      oCtrlDef.Execute

End Sub

 

René J

0 Likes
Message 12 of 19

MjDeck
Autodesk
Autodesk

Rene,

 

 The Set keyword doesn't work in iLogic (which is based on VB.NET).  If that code works in VBA, then this should work in iLogic:

 

Dim oCtrlDef As ControlDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("autodesk:iflatpatternexport:iexpflatpatterncmdbtn")
oCtrlDef.Execute


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 13 of 19

Rene-J
Collaborator
Collaborator

Thanks Mike

I have changed my post

René J

0 Likes
Message 14 of 19

rjay75
Collaborator
Collaborator

I actually have a complete add-in that is currently being tested that specifically automates exporting individual and multiple flat patterns of parts in customizable formats. If it will be of help and you'd like to test it out let me know.

0 Likes
Message 15 of 19

Anonymous
Not applicable

Rene, thanks for the link to the program. It works great, the onlt problem im having is that the "on save creat flatpattern if not exist" doesnt seem to want to stay checked. any reason for this?

0 Likes
Message 16 of 19

Rene-J
Collaborator
Collaborator

Thanks

I have uploaded a new vers.

Create flatpattern if not exist, don't show in dialogbox as checked is solved.

 

René J

0 Likes
Message 17 of 19

Anonymous
Not applicable

rjay75,

I would love to try out your Addin.

 

What I am working on is some iLogic code in Inventor 2012 to create four formed views of a sheet metal part using the IDW template and then also add a sheet metal flat pattern view. I am able to achieve the four formed views but I do not know or have the proper code to create the flat pattern view in the idw.

 

If you have it handy, please send me the link to your Addin. If you have the solution to my current problem, that would be much appreciated.

 

Raj Thapa

0 Likes
Message 18 of 19

Rene-J
Collaborator
Collaborator
0 Likes
Message 19 of 19

zyg64
Explorer
Explorer

I need this iFlatpatternExport Add-in, I was using with Inventor 2014, for Inventor 2017.

I wonder if anybody knows on how to install the version 2012 into Inventor 2017

Thanks,

Z

0 Likes