ilogic for creating flat pattern for sheet metal assembly.

ilogic for creating flat pattern for sheet metal assembly.

Anonymous
Not applicable
7,891 Views
8 Replies
Message 1 of 9

ilogic for creating flat pattern for sheet metal assembly.

Anonymous
Not applicable

ilogic for creating flat pattern for sheet metal assembly.

0 Likes
Accepted solutions (1)
7,892 Views
8 Replies
Replies (8)
Message 2 of 9

ratneshmalik1990
Contributor
Contributor

https://forums.autodesk.com/t5/inventor-forum/ilogic-sheet-metal-flat-pattern/td-p/3405243

Autodesk Inventor Certified Professional | Mechanical Design Engineer
Message 3 of 9

S_May
Mentor
Mentor
Accepted solution

Hi @Lakshmana.kumar

 

https://knowledge.autodesk.com/de/community/screencast/ecfa2a59-e898-43be-8177-14e802d9cf8b

 

 

 

 

'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)
'check that the active document is an assembly file
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If
'get user input
RUsure = MessageBox.Show ( _
"This will create a DXF file for all of the asembly components that are sheet metal." _
& vbLf & "This rule expects that the part file is saved." _
& vbLf & " " _
& vbLf & "Are you sure you want to create DXF for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic - Batch Output DXFs ",MessageBoxButtons.YesNo)
If RUsure = vbNo Then
Return
Else
End If
oPath = ThisDoc.Path
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
'get DXF target folder path
oFolder = oPath & "\" & oAsmName & " DXF Files"
'Check for the DXF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
'- - - - - - - - - - - - -
'- - - - - - - - - - - - -Component - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
'work the the drawing files for the referenced models
'this expects that the model has been saved
For Each oRefDoc In oRefDocs
iptPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "ipt"
'check that model is saved
If(System.IO.File.Exists(iptPathName)) Then
Dim oDrawDoc As PartDocument
oDrawDoc = ThisApplication.Documents.Open(iptPathName, True)
oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName))
Try
'Set the DXF target file name

Try
CustomName =iProperties.Value(oFileName, "Custom", "PF_PRT_ZNR")
Catch
CustomName ="XXX" 'Wert, wenn iPropertie PF_PRT_ZNR nicht existiert
End Try

oDataMedium.FileName = oFolder & "\" & CustomName  & " " & oFileName & ".dxf"

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDrawDoc.ComponentDefinition
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If
Dim sOut As String
sOut = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=IV_OUTER_PR​OFILE"
oCompDef.DataIO.WriteDataToFile( sOut, oDataMedium.FileName)
'just for check its works coretcly
'i=MessageBox.Show(oDataMedium.FileName, "Title",MessageBoxButtons.OKCancel)
'MessageBox.Show(i,"title",MessageBoxButtons.OK)
'If i=2 Then
'Exit Sub
'End If
oCompDef.FlatPattern.ExitEdit
Catch
End Try
oDrawDoc.Close
Else
End If
Next
Message 4 of 9

Anonymous
Not applicable

@S_May,

 

Excellent, but I am looking for code which creates only flat pattern for parts in assembly, in your code it includes both creation of flat pattern as well as exporting dxf file.

 

I don't have much knowledge about script, can you please provide the code up to creation of flat pattern.

 

Thanks,

Lakshmana Kumar

0 Likes
Message 5 of 9

russell
Explorer
Explorer
This rule is fantastic. I've imbedded it in my standard assembly template with a couple of tweaks. Next level: Do you have a rule for also creating a drawing and placing each part, say top view, along with a flat pattern on a sheet? Or could you guide me on how to get started with the iLogic? Thanks, Russ
Message 6 of 9

Anonymous
Not applicable

When I try to use this in Inventor Professional 2018 it says that "let and set assignment statements are no longer supported and that method arguments must be in parentheses.  I know nothing about coding so if you know how to fix this issue it would be greatly appreciated. 

0 Likes
Message 7 of 9

Joshua-Hayward
Explorer
Explorer

Really like this Ilogic rule, however do you know if there is anyway to apply a configuration file to the export?

0 Likes
Message 8 of 9

ktsaleej
Enthusiast
Enthusiast

 

In here you can generate AutoLISP(.lsp) program to draw the development of geometric shapes in AutoCAD. This drawing you can directly transfer to your cnc plate cutting machines to cut the plate. Just select shape which you want to draw and fill the form, You can generate your AutoLISP(.lsp) program.

Development

0 Likes
Message 9 of 9

a.kuznetcov
Observer
Observer

Hey, guys! Can somebody explain to me in simple words? Why enter these variables? What do they mean?  Thank you for you help.

oPath = ThisDoc.Path
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap

 

0 Likes