03-06-2021
10:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-06-2021
10:09 AM
Hello
Which row of your Code is right? It seems you mixed two scripts together.
Is your script called by another script or should it run alone? I assume you calling this script by a Main sub. You will have to fill the string variables for template name and output path. There is a shared variable "VPR_Codice" and I assume it is set elsewhere. There is a variable "pathOutputLamieraDXF" used, but not set anywhere.
I've commented unused code.
Perhaps it will help, otherwise you have to post more details. It didn't run correctly is a little bit less information. ![]()
Sub Main()
Dim IPT_OM_Template As String = "" '<--- Fill missing Text
Dim pathOutputDXF As String = "" '<--- Fill missing Text
Call Print_Assembly_IPT_DXF(IPT_OM_Template, pathOutputDXF)
End Sub
'IPT_OM_template is the name of Assembly in the rule
Sub Print_Assembly_IPT_DXF(IPT_OM_Template As String, pathOutputDXF As String)
Dim oAsm As AssemblyDocument = ThisDoc.Document
'Dim oPenDoc As Document=ThisDoc.Document
Dim AsmCompDefMainL0 As AssemblyComponentDefinition = oAsm.ComponentDefinition 'ThisApplication.ActiveDocument.ComponentDefinition
Dim AsmCompDefL1 As AssemblyComponentDefinition '= ThisApplication.ActiveDocument.ComponentDefinition
Dim OccurMainL0 As ComponentOccurrence
Dim OccurL1 As ComponentOccurrence
'Dim AsmCompMainL0 As ComponentDefinition = ThisDoc.Document.ComponentDefinition
'Dim AsmCompMainL1 As ComponentDefinition = ThisDoc.Document.ComponentDefinition
For Each OccurMainL0 In AsmCompDefMainL0.Occurrences
Dim oOccNameL0 As String = OccurMainL0.Name
Dim thisAssembly As AssemblyDocument = oOccNameL0
Logger.Info("Apro assieme per DXF: " & oOccNameL0)
If OccurMainL0.Definition.Type = ObjectTypeEnum.kAssemblyComponentDefinitionObject Then
For Each OccurL1 In OccurMainL0.SubOccurrences
'For Each doc In thisAssembly.AllReferencedDocuments
If OccurL1.Definition.Type=ObjectTypeEnum.kSheetMetalComponentDefinitionObject Then
Dim parsedPartName = OccurL1.ReferencedDocumentDescriptor.DisplayName ' doc.DisplayName
Logger.Info("Selezionare parte da esportare in DXF: " & parsedPartName)
If parsedPartName.Contains("CTG") Then
Logger.Info("Ho selezionato la parte in CTG")
Else
Logger.Info("Ho selezionato la parte in lamiera")
Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=OUTER_PROFILE&OuterProfileLayerColor=0;0;0&InteriorProfilesLayer=INNER_PROFILE&InteriorProfilesLayerColor=0;0;0&InvisibleLayers=IV_BEND;IV_BEND_DOWN;IV_UNCONSUMED_SKETCH;IV_ARC_CENTERS;IV_TANGENT;IV_ROLL;IV_ROLL_TANGENT;IV_ALTREP_BACK;IV_ALTREP_FRONT;IV_FEATURE_PROFILES_DOWN;IV_FEATURE_PROFILES;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;DIGI_MARKER_TOOL_1;DIGI_MARKER_TOOL_2"
Dim component As SheetMetalComponentDefinition = OccurL1.Definition
'Dim PathDXF As String = pathOutputLamieraDXF & iProperties.Value(OccurL1, "Custom", "Nome_File")
component.Unfold
If System.IO.File.Exists(pathOutputDXF) = True Then
System.IO.File.Delete(pathOutputDXF)
End If
'component.DataIO.WriteDataToFile(sOut, pathDXF)
component.DataIO.WriteDataToFile(sOut, pathOutputDXF )
Logger.Info("DXF " & SharedVariable("VPR_Codice") & " SUCCESS")
component.FlatPattern.ExitEdit()
'component.Document.close()
End If
End If
Next
End If
Next
End Sub
R. Krieg
RKW Solutions
www.rkw-solutions.com