Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Guys,
I've got a code running to export dxf files to a certain DXF-folder and that's working great.
The guys of the production department would like to have the dxf's sorted in different folders with the material and thickness as foldername.
The current foldername is as follows:
oFolder = oPath & "\" & oAsmName & "-Rev_" & oRevNum & "-PF" & "\" & oAsmName & "-Rev_" & oRevNum & "-DXF"
I would like to get ActiveSheetMetalStyle.Name from the different sheetmetal parts in an assembly and use that to create a new folder for that type of material and thickness.
Thus adding an aditional folder like "\"Steel 3mm or AISI 304 5mm etc...
Could somebody help me out as I haven't got the required knowledge to get the information from the sheetmetal part.
SyntaxEditor Code Snippet
'define the active document as an assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4) oRevNum = iProperties.Value("Project", "Revision Number") '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 assembly components that are sheet metal." _ & vbLf & "This rule expects that the part file is saved." _ & vbLf & "Only sheet metal parts with their BOM-structure set to normal will be exported" _ & vbLf & " " _ & vbLf & "Are you sure you want to create DXF for all of the assembly sheet metal components?" _ & vbLf & " " _ & vbLf & "This could take a while.", "iLogic - Batch Output DXFs ",MessageBoxButtons.YesNo) If RUsure = vbNo Then Return Else End If '- - - - - - - - - - - - -Component - - - - - - - - - - - - 'look at the files referenced by the assembly Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document 'work the drawing files for the referenced models 'this expects that the model has been saved For Each oRefDoc In oRefDocs 'check if the document is a sheet metal part If oRefDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For 'check if the BOM-structure is set to normal If oRefDoc.ComponentDefinition.BOMStructure <> BOMStructureEnum.kNormalBOMStructure Then Continue For iptPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "ipt" 'check that the 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)- 3) On Error Resume Next 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 & "-Rev_" & oRevNum & "-PF" & "\" & oAsmName & "-Rev_" & oRevNum & "-DXF" If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 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_PR?OFILE" 'sOut = "FLAT PATTERN DXF?AcadVersion=2004&RebaseGeometry=True&OuterProfileLayer=0&OuterProfileLayerColor=0;0;0&InteriorProfilesLayer=0&InteriorProfilesLayerColor=0;0;0&BendDownLayerColor=255;0;0&BendUpLayerColor=255;0;0&BendDownLayerLineType=37641&BendUpLayerLineType=37639IV_BEND;IV_BEND_DOWN;IV_OUTER_PROFILE;IV_INTERIOR_PROFILES;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_ROLL_TANGENT;IV_ROLL&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_UNCONSUMED_SKETCHES" sOut = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=0&OuterProfileLayerColor=0;0;0&InteriorProfilesLayer=0&InteriorProfilesLayerColor=0;0;0&BendDownLayerColor=255;0;0&BendUpLayerColor=0;128;255&BendDownLayerLineType=37633&BendUpLayerLineType=37641;IV_BEND;IV_BEND_DOWN;IV_OUTER_PROFILE;IV_INTERIOR_PROFILES;IV_FEATURE_PROFILESLayer=engrave;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_ROLL_TANGENT;IV_ROLL&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_UNCONSUMED_SKETCHES;IV_FEATURE_PROFILES_DOWN" oCompDef.DataIO.WriteDataToFile( sOut, oDataMedium.FileName) oCompDef.FlatPattern.ExitEdit oDrawDoc.Close End If Next MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") 'open the folder where the new ffiles are saved Shell("explorer.exe " & oFolder,vbNormalFocus)
Solved! Go to Solution.