- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hello, I need some help ...
i have an assembly file with ilogic rules and part and subassemblies.
according to certain ilogic rules I need to export only the visible elements and not all the parts present in the assembly to file step.
I found a rule already made and it works but not as I would like.
the problem is this rule exports the visible files but also the derivatives which, however, are not visible in the assembly.
how could I do not to make it exhibit a derivative part.
the derived part is used for a mirrored part so in my assembly it is not visually present.
I can't delete the link with the derived part because it's all parametric and I need the parameters
the rule I am using is this:
Sub Main()
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)
'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
' If MessageBox.Show ( _
' "This will create a STP file for all of the asembly components that have drawings files." _
' & vbLf & "This rule expects that the drawing file shares the same name and location as the component." _
' & vbLf & " " _
' & vbLf & "Are you sure you want to create STP Drawings for all of the assembly components?" _
' & vbLf & "This could take a while.", "iLogic - Batch Output STPs ",MessageBoxButtons.YesNo) = vbNo Then
'
' Exit Sub
' End If
Dim STEPTranslator As TranslatorAddIn
Dim oContext As TranslationContext
Dim oOptions As NameValueMap
Dim oDataMedium As DataMedium
Call ConfigureSTEPTranslatorSettings(STEPTranslator, oContext, oOptions, oDataMedium)
'oPath = ThisDoc.Path
oFolder = "C:\Users\STEFANIA\Desktop\Nuova cartella (3)" & "\" & oAsmName & " STEP Files"
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
'- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - -'
'look at the files referenced by the assembly
Dim oRefDoc As Document
For Each oRefDoc In oAsmDoc.AllReferencedDocuments
idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw"
' If(System.IO.File.Exists(idwPathName)) Then
Dim oSTEPDoc As Document
oSTEPDoc = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)
oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -4)
' oRevNum = oDrawDoc.PropertySets.Item("Inventor Summary Information").Item("Revision Number").Value
'oDesc = oRefDoc.iProperties.Value("Project", "Description")
oDesc = oSTEPDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value
'********************For Each oRefDoc In oRefDocs
iptPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "ipt"
'check that 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))
End If
'**********************
'
On Error Resume Next
' 'Set the STP target file name
' If oRevNum = Nothing Then
' oDataMedium.FileName = oFolder & "\" & oFileName & ".STP"
oSTEPDoc.SaveAs(oFolder & "\" & oFileName &"_"& Parameter ("sospensione") & oDesc & (".stp") , True)
'
' Else
' oDataMedium.FileName = oFolder & "\" & oFileName & ".STP"
' End If
Call STEPTranslator.SaveCopyAs(oSTEPDoc, oContext, oOptions, oDataMedium)
oRefDoc.Close
On Error Goto 0
' End If
Next
'- - - - - - - - - - - - -
'- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - -
' Dim oAsmDrawingDoc As DrawingDocument
' oAsmDrawingDoc = ThisApplication.Documents.Open(ThisDoc.ChangeExtension(".idw"), True)
' oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -4)
' oAsmDrawingRev = oAsmDrawingDoc.PropertySets.Item("Inventor Summary Information").Item("Revision Number").Value
'
' On Error Resume Next
' 'Set the PDF target file name
' If oAsmDrawingRev = Nothing Then
' oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & ".pdf"
'
' Else
' oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & " Rev." & oRevNum & ".pdf"
'
' End If
'
' Call PDFAddIn.SaveCopyAs(oAsmDrawingDoc, oContext, oOptions, oDataMedium)
' oAsmDrawingDoc.Close
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic")
Shell("explorer.exe " & oFolder,vbNormalFocus)
End Sub
Sub ConfigureSTEPTranslatorSettings(ByRef STEPTranslator As TranslatorAddIn, ByRef oContext As TranslationContext, ByRef oOptions As NameValueMap, ByRef oDataMedium As DataMedium)
oPath = ThisDoc.Path
oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
' Set application protocol.
' 2 = AP 203 - Configuration Controlled Design
' 3 = AP 214 - Automotive Design
oOptions.Value("ApplicationProtocolType") = 3
' Other options...
'oOptions.Value("Author") = ""
'oOptions.Value("Authorization") = ""
'oOptions.Value("Description") = ""
'oOptions.Value("Organization") = ""
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Dim oData As DataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
oDataMedium.FileName = ThisDoc.PathAndFileName(False) & ".stp"
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oDataMedium)
End If
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
End Sub
Solved! Go to Solution.