flat pattern generation from assembly

flat pattern generation from assembly

Anonymous
Not applicable
823 Views
2 Replies
Message 1 of 3

flat pattern generation from assembly

Anonymous
Not applicable

Hi,

 

I have some problem with ILogic. I'm trying to do some rule to generate .dxf files of flat pattern form each sheet metal parts.  I have rule that works in single part document but i cant create it for assembly.

 

I would like to run this rule manually when i finish each project. And i want to all those .dxf be in one folder called "DXF" just like my rule.

 

Here goes my code for single .ipt

 

i = MessageBox.Show("Czy chcesz zapisać rozwinięcie blachy?", "Zapis .dxf", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
	If (i=6)
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
''ThisDoc.Launch(ThisDoc.PathAndFileName(True))
Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDoc.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_PROFILE"
    
Dim sFname As String

sFname = ThisDoc.FileName(False)


'sFname = Left$(sFname, Len(sFname)-4) & ".dxf"
oPath = ThisDoc.Path

oFolder = oPath & "\" & "DXF"

If Not System.IO.Directory.Exists(oFolder) Then
    System.IO.Directory.CreateDirectory(oFolder)
End If


sciezka = oFolder & "\" & sFname & ".dxf"


oCompDef.DataIO.WriteDataToFile( sOut, sciezka)
oCompDef.FlatPattern.ExitEdit
''ThisDoc.Document.Close


	End If

 

It works great for me. 

 

Can someone can help me with this?

0 Likes
Accepted solutions (1)
824 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Well, its looks like ive done it by myself with connecting a few codes and changing them a little bit.

 

It works. Rule for each sheet metal save .DXF unfolded copy on special folder where assembly is. 

 

perhaps this code is too complicated but it works for now , later I will improve it

 

'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
                	oDataMedium.FileName = oFolder & "\" & 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_PROFILE"

					
					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
0 Likes
Message 3 of 3

Anonymous
Not applicable

I know this post is old but if you see this do you know if there is a way to change the export settings in the rule?  I want it to put the all the profiles on one layer all the bend on one layer and omit the tangent lines and arc centers.  any help would be greatly appreciated.  

0 Likes