Message 1 of 2
Is it possible to search in drawing for Revision number?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am using this code
'define the active document as an assembly file
Dim oInvApp As Inventor.Application = ThisApplication
'make sure that the active document is an assembly file
If oInvApp.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the build file.", "iLogic")
Exit Sub
End If
Dim oAsmDoc As AssemblyDocument = oInvApp.ActiveDocument
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)
oRevNum = iProperties.Value("Project", "Revision Number")
Dim oProjectNumber As String = Mid(oFilePath, 56, 6)
oPath = "C:\Exports\01 - DXF Exports" & oProjectNumber & "\"
'Getting User input
RUsure = MessageBox.Show ( _
"This will create a DXF file for all the components of the assembly made of sheet metal." _
& vbLf & "This rule assumes that the part file will be saved." _
& vbLf & "Only sheet metal parts for which the specification structure is set to the normal value will be exported" _
& vbLf & " " _
& vbLf & "Are you sure you want to create a DXF for all the components of a sheet metal assembly?" _
& vbLf & " " _
& vbLf & "This may take some time.", "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 = oAsmDoc.AllReferencedDocuments
'process the drawing files for the referenced models
'at the same time, it is expected that the model has been saved
For Each oRefDoc As Document 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 normal structure of the specification is set
If oRefDoc.ComponentDefinition.BOMStructure <> BOMStructureEnum.kNormalBOMStructure Then Continue For
'make sure that the model is saved
If Not System.IO.File.Exists(oRefDoc.FullFileName) Then Continue For
Dim oPDoc As PartDocument = oInvApp.Documents.Open(oRefDoc.FullFileName, True)
Dim oSheetDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
Dim ThicknessSM As Inventor.Parameter = oSheetDef.Thickness
Dim Thickness As String=ThicknessSM.Value * 10
oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName)- 4)
On Error Resume Next
oStyle = oSheetDef.ActiveSheetMetalStyle.Name
Dim oTO As TransientObjects = oInvApp.TransientObjects
oDataMedium = oTO.CreateDataMedium
oContext = oTO.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = oTO.CreateNameValueMap
Dim oPropSet As PropertySet = oInvApp.PropertySets.Item("Inventor Summary Information")
Dim oProp As Inventor.Property = oPropSet.Item("Revision Number")
oRevNum = oProp.Value
If oRevNum = "-" Then oRevNum = ""
If oRevNum = "" Then
oRevtxt = ""
Else
oRevtxt = " - REV"
End If
'get the path to the target folder DXF
oFolder = oPath & "\" & oAsmName & "\" & oStyle & "\" & Thickness
If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder)
oDataMedium.FileName = oFolder & "\" & oFileName & " - " & oRevtxt & oRevNum & ".dxf"
' & oPDoc.ActiveMaterial.DisplayName & VOOR ALS JE MATERIAAL WILT TOEVOEGEN AAN DE BENAMING
If oSheetDef.HasFlatPattern = False Then
oSheetDef.Unfold
Else
oSheetDef.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=2018&MergeOuterContour=True&MergeProfilesIntoPolyline=True&RebaseGeometry=True&Feature" _
+ "&FeatureProfilesLayer=IV_FEATURE_PROFILES&FeatureProfilesLayerColor=0;255;255&FeatureProfilesDownLayer=IV_FEATURE_PROFILES_DOWN&FeatureProfilesDownLayerColor=0;255;255" _
+ "&InvisibleLayers=IV_TANGENT;IV_BEND;IV_BEND_DOWN;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL"
oSheetDef.DataIO.WriteDataToFile( sOut, oDataMedium.FileName)
oSheetDef.FlatPattern.ExitEdit
oPDoc.Close()
Next
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic")
'open the folder where the new ffiles are saved
Shell("explorer.exe " & oPath,vbNormalFocus)
And I was wondering if it is possible, that it searches for the revision number in the drawing instead of the part it self?
Ciao