Message 1 of 1
iLogic (or Macro) to create drawings for iParts as they are exported to unique members
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an iPart with thousands of rows. There is an iLogic rule in the part which takes each row of the iPart and exports it to a unique part. I did not create this rule, I assume it came from this forum.
The rule works great, but I am hoping to expand on it and have it copy the drawing for this iPart and replace the model reference as it goes through and creates the individual members.
Has anyone seen anything like this?
See the existing iLogic "unique part" rule below.
Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
oCompDef = partDoc.ComponentDefinition
'get the name of the iPart parent
Dim iPartParentName As String = ThisDoc.FileName(False) 'without extension
'create a folder for the exported models, in the same location as the parent iPart
Dim oFolder As String
oFolder = ThisDoc.Path & "\" & iPartParentName & " EXPORTED MODELS"
If System.IO.Directory.Exists(oFolder) = False Then
System.IO.Directory.CreateDirectory(oFolder)
ElseIf System.IO.Directory.Exists(oFolder) = True Then
'option if exists
End If
'get the number of ipart members
Dim iPartRows As Integer = oCompDef.iPartFactory.TableRows.count()
'now for each iPart member we will export a new model
Dim currentrow As Integer
For currentrow = 1 To iPartRows
'activate the currentrow
iPart.ChangeRow("", currentrow)
'here the part number of the current member will be used to save the new exported model
'this could be any combination of properties you choose
Dim partno As String = iProperties.Value("Project", "Part Number")
'now we save a copy of the iPart with the new name, in the new folder
Dim NewFileNameAndExtension As String = oFolder & "\" & partno & ".ipt"
ThisDoc.Document.SaveAs(NewFileNameAndExtension , True)
'now we open the newly created file
ThisDoc.Launch(NewFileNameAndExtension)
ExportedPart = ThisApplication.Documents.ItemByName(NewFileNameAndExtension)
'define the ilogicAutomation
Dim iLogicAuto As Object
iLogicAuto = iLogicVb.Automation
'get the rule that will revert the model to a standard part, it will automatically
'appear in the newly created file if it is in the base iPart
Dim oRuleName As String = "iPartExport"
Dim oRule As Object
oRule = iLogicAuto.GetRule(ExportedPart, oRuleName)
'run the rule in the new file
iLogicAuto.RunRuleDirect(oRule)
'close the file
ExportedPart.Close
Next
Owner / Designer
Modern 3Design
Modern 3Design