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

See if this works for you.

From the looks of the StatusBar message, this is just a portion of a larger code, so I'm not sure if this is the main part, or if this is the lower Sub part.  If this portion of the code is not the main top code in your rule, you likely need to change Sub Main() to something else like Sub FlatPatternToSAT().

I also put a check in there, because the WorkspacePath can be empty, if not defined within your Project file.  I also showed an alternate way to get that info, commented out.

As far as the version, I couldn't find any examples of other entries in place of "ACIS SAT".

I tried using the Sub: DataIO.GetOutPutFormats(), but it was constantly throwing errors, so I never was able to get the results.  I tried it on the ComponentDefinition, the FlatPattern, on FlatPattern.SolidBodies.Item(1).DataIO, but always errors.  There is very little documentation about using DataIO's on here, other that where others have tried to use it at some point in the past.  The only official example using it is for DXF's.

Sub Main
	Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
	If iProperties.Value("Project", "Revision Number") = "" Then
		iProperties.Value("Project", "Revision Number") = "0"
	End If
	Dim oRev As String = iProperties.Value("Project", "Revision Number")
	''If oPDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	If oPDoc.PropertySets.Item("Design Tracking Properties").Item("Document SubType Name").Value = "Sheet Metal" Then
		Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
		If oSMDef.FlatPattern Is Nothing Then 
			oSMDef.Unfold
			oSMDef.FlatPattern.ExitEdit
		End If
	''	Dim oWSP As String = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
		If ThisDoc.WorkspacePath = "" Then
			MsgBox("ThisDoc.WorkspacePath is empty (not defined). Exiting.", vbOKOnly + vbExclamation, "WORKSPACE NOT DEFINED")
			Return 'or Exit Sub
		End If
		Dim oPathSat As String = ThisDoc.WorkspacePath & "\SAT\"
		If Not System.IO.Directory.Exists(oPathSat) Then
			System.IO.Directory.CreateDirectory(oPathSat)
		End If
	''	Version = 7
		Dim oFileName As String = oPathSat & ThisDoc.FileName(False) & "_REV-" & oRev & ".sat"
		Try
			oSMDef.FlatPattern.DataIO.WriteDataToFile("ACIS SAT", oFileName)
		Catch oEx As Exception
			MsgBox("DataIO.WriteDataToFile() failed!" & vbCrLf & _
			"Error Message is as follows:" & vbCrLf & _
			oEx.Message & vbCrLf & vbCrLf  & _
			"Error Source is as follows:" & vbCrLf & _
			oEx.Source & vbCrLf & vbCrLf & _
			"Error StackTrace is as follows:" & vbCrLf & _
			oEx.StackTrace & vbCrLf & vbCrLf  & _
			"Error Type.ToString is as follows:" & vbCrLf & _
			oEx.GetType.ToString, vbOKOnly + vbInformation, " ")
		End Try
	Else
		ThisApplication.StatusBarText = ThisDoc.FileName(False) & " Is not in a sheet metal state, convert to sheetmetal and create flat pattern first --- Jumping to next part" 
	End If
End Sub

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)