- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I have a litteral ton of iParts that I need to edit in the coming days.
All of them need this done:
They are iParts, the children of the parent so to speak.
I need to break the link with the parent.ipt
There are also a bunch of iLogic rules that are in the event triggers. Some external and some internal. all of them need to be removed.
Then lastly I want to save the file but I know how to so that XD
-------------
I found this but I'm having trouble finding good sources on how to break a link with a parent in just one IPT.
Can anyone point me in the direction on how to tackle this
The iPartMember Object has the gives the breaklinktofile method but I'm not sure on how to implement it.
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
___________________________Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You can run this on the iPart factory (parent file) to break the link of all the ipart members (children)
Dim oParent As iPartFactory oParent = ThisDoc.Document.ComponentDefinition.iPartFactory Dim oRow As iPartTableRow For Each oRow In oParent.TableRows oParent.CreateMember(oRow).BreakLinkToFactory Next
You can try this to delete event triggers
Sub Main
oDoc = ThisApplication.ActiveEditDocument
'---------------------------------------------------------
'[ delete all existing event triggers
'Get access to the set of Event Triggers
Dim oEventTriggersSet As PropertySet
oEventTriggersSet = GetEventTriggersSet(oDoc)
Dim oRuleTrigger As Inventor.Property
For Each oRuleTrigger In oEventTriggersSet
oRuleTrigger.Delete
Next
']
End Sub
Function GetEventTriggersSet(oDoc As Document) As Inventor.PropertySet
On Error Resume Next
oEventTriggersSet = oDoc.PropertySets.Item("iLogicEventsRules")
If oEventTriggersSet Is Nothing Then
oEventTriggersSet = oDoc.PropertySets.Item("_iLogicEventsRules")
End If
If oEventTriggersSet.InternalName <> "{2C540830-0723-455E-A8E2-891722EB4C3E}" Then
Call oEventTriggersSet.Delete
oEventTriggersSet = oDoc.PropertySets.Add("iLogicEventsRules", "{2C540830-0723-455E-A8E2-891722EB4C3E}")
End If
If oEventTriggersSet Is Nothing Then
oEventTriggersSet = oDoc.PropertySets.Add("iLogicEventsRules", "{2C540830-0723-455E-A8E2-891722EB4C3E}")
End If
If oEventTriggersSet Is Nothing Then
Trace.WriteLine("!!!!!!! oEventTriggersSet is Nothing !!!!!!", "iLogic") ''debug
'Logger.Info("!!!!!!! oEventTriggersSet is Nothing !!!!!!")
Exit Function
End If
On Error Goto 0
Return oEventTriggersSet
End Function
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
That's perfect @Curtis_Waguespack Thank you!
This will save me hours!
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
___________________________- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I tried editting it so it'd work for iAssembles as well but there's a compiler error I'm getting
RUsure = MessageBox.Show("This rule MUST be run on the iPart Master part. It will break all links with the children. CONTINUE?", "BULK DRAWING TOOL", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If RUsure = vbNo Then Exit Sub 'User wants to quit the Rule. End If Dim oParentPart As iPartFactory Dim oParentAssy As iAssemblyFactory Dim oRow As iPartTableRow Dim oRowAssy As iAssemblyTableRow On Error Resume Next oParentPart = ThisDoc.Document.ComponentDefinition.iPartFactory oParentAssy = ThisDoc.Document.ComponentDefinition.iAssemblyFactory For Each oRow In oParentPart.TableRows oParentPart.CreateMember(oRow).BreakLinkToFactory Next For Each oRowAssy In oParentAssy.TableRows oParentAssy.CreateMember(oRowAssy).BreakLinkToFactory Next MessageBox.Show("End of rule reached", "Title")
The oParentAssy.CreateMember(oRowAssy).BreakLinkToFactory
doesn't produce a value it says...
Any tips?
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
___________________________- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This should output the member files (the same as right clicking on the members in the browser and choosing Generate Files) however it does't work... so that is why the break link function does not work.
I'm not sure why this is not working in iAssemblies, there might simply be something else we have to do first, but I'm not sure.
Dim oParent As iAssemblyFactory oParent = ThisDoc.Document.ComponentDefinition.iAssemblyFactory Dim oRow As iAssemblyTableRow For Each oRow In oParent.TableRows oParent.CreateMember(oRow) Next
In any case, here is an example that gets the iAssembly cache folder from the factory file, and opens each assembly, then checks to make sure it is an iAssembly member and then breaks the link, saves and closes
Dim oParent As iAssemblyFactory oParent = ThisDoc.Document.ComponentDefinition.iAssemblyFactory Dim oRow As iAssemblyTableRow Dim oDoc As AssemblyDocument Dim oDef As AssemblyComponentDefinition oMemberFolder = oParent.MemberCacheDir Dim fileEntries As String() = System.IO.Directory.GetFiles(oMemberFolder,"*.iam") Dim fileName As String For Each fileName In fileEntries oDoc = ThisApplication.Documents.Open(fileName, False) oDef = oDoc.ComponentDefinition If oDef.IsiAssemblyMember Then oMember = oDef.iAssemblyMember oMember.BreakLinkToFactory oDoc.save End If oDoc.close Next
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @Curtis_Waguespack ,
Hope you are doing well, I tired to do the file generation for IPT and break link, it is working for few components and if i close those members and open them again, the link is still there. Can you tell me what would be causing this.
Thanks!