Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Ralf_Krieg
in reply to: Anonymous

Hello

 

We can use the A-Side definition only if the model is unfolded. If the user suppress this feature or refold the model, the face is not planar and useless. Is there a reason for not using the flat pattern? If we create a flat pattern, we can obtain the top face for export. It's the face you look at if the flat pattern environment is activated.

I've added both possibilities to the script. If an A-Side definition is found and no flat pattern exist, the A-Side definition is used. If a flat pattern exist, the top face of flat pattern is used.

Can you try it out?

 

	
Private Sub Main()

Dim oApp As Inventor.Application = ThisApplication

'check that this active document is a part file
If oApp.ActiveDocument.DocumentType <> kPartDocumentObject Then
    Call MsgBox("Please open a part document", "iLogic")
    Exit Sub
End If

Dim oPartDoc As PartDocument = oApp.ActiveDocument

If Not oPartDoc.ComponentDefinition.Type = ObjectTypeEnum.kSheetMetalComponentDefinitionObject
	Call MsgBox("Part document must be a sheet metal part", "iLogic")
    Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition

Dim oASide As Face
If oCompDef.ASideDefinitions.Count > 0 Then
	oASide= oCompDef.ASideDefinitions.Item(1).ASideFace
End If
If oCompDef.HasFlatPattern = True Then
	oASide = oCompDef.FlatPattern.TopFace
End If

If oASide Is Nothing Then
	Call MsgBox("Please create an A-Side definition or a flat pattern first", "iLogic")
    Exit Sub
End If

Dim sFolder = ThisDoc.Path & "\DXF\"
Dim sFilename = ThisDoc.FileName(False)
Dim sFullFilename As String = sFolder & sFilename & ".dxf"

Try
	Dim oDirInfo As System.IO.DirectoryInfo= System.IO.Directory.CreateDirectory (sFolder)
Catch
	Call MsgBox("Could not create target folder. Missing write access?", "ilogic")
	Exit Sub
End Try

'add filename to memory for file save dialog
Dim Cm As CommandManager = oApp.CommandManager
Cm.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, sFullFilename )

Dim oSelectSet As SelectSet = oPartDoc.SelectSet
oPartDoc.SelectSet.Clear()
Call oPartDoc.SelectSet.Select(oASide)

Dim oCtrlDef As ButtonDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")
Call oCtrlDef.Execute

oPartDoc.SelectSet.Clear()

End Sub

 


R. Krieg
RKW Solutions
www.rkw-solutions.com