Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there a way to suppress or activate a feature (extrusion, revolve, etc) of part model state from assembly with iLogic?
Solved! Go to Solution.
Is there a way to suppress or activate a feature (extrusion, revolve, etc) of part model state from assembly with iLogic?
Solved! Go to Solution.
Here is an example of that:
Dim oAss As AssemblyDocument = ThisApplication.ActiveDocument Dim oOcc As ComponentOccurrence = oAss.ComponentDefinition.Occurrences.Item(4) Dim oCompDef As PartComponentDefinition = oOcc.Definition Dim oPartDoc As PartDocument = oOcc.Definition.Document Dim oMSDoc As PartDocument oMSDoc = oPartDoc.ComponentDefinition.ModelStates.ActiveModelState.Document oMSDoc.ComponentDefinition.Features.Item("Extrusion1").Suppressed = True
Edit.... I tried this again and it didnt work for me. using the 'ActiveModelState' was giving me trouble. This seems to be working(for now)...........
Dim oAss As AssemblyDocument = ThisApplication.ActiveDocument Dim oOcc As ComponentOccurrence = oAss.ComponentDefinition.Occurrences.Item(4) Dim oPartDoc As PartDocument = oOcc.Definition.Document Dim oMSDoc As PartDocument oMSDoc = oPartDoc.ComponentDefinition.ModelStates.Item("9FT").Document oOcc.Edit oMSDoc.ComponentDefinition.Features.Item("Extrusion1").Suppressed = False oOcc.ExitEdit(ExitTypeEnum.kExitToPrevious)
Hi,
I tried with your rules, but I am not sure why it is giving me some error.. would you mind share with me your file to study as I am still very new in this area. I have put down some notes below as per my understanding.. correct me if I am wrong.
Dim oOcc As ComponentOccurrence = oAss.ComponentDefinition.Occurrences.Item(4) ---> this is to access to Item 4 counted from the model tree
Dim oPartDoc As PartDocument = oOcc.Definition.Document --> this is to access Item 4 part document as oOcc has been defined to Item 4
Dim oMSDoc As PartDocument
oMSDoc = oPartDoc.ComponentDefinition.ModelStates.Item("9FT").Document --> this is to access the model states called 9FT
oOcc.Edit --> to edit the occurrences
oMSDoc.ComponentDefinition.Features.Item("Extrusion1").Suppressed = False --> to edit the feature
oOcc.ExitEdit(ExitTypeEnum.kExitToPrevious) ---> is this to close the .ipt file?
I created part and assembly to test on the rule as below, but giving me problem.. I have attached the files which give me error..
Hope you can advise me on this
-------------------------------
Dim oAss As AssemblyDocument = ThisApplication.ActiveDocument
Dim oOcc As ComponentOccurrence = oAss.ComponentDefinition.Occurrences.Item(1)
Dim oPartDoc As PartDocument = oOcc.Definition.Document
Dim oMSDoc As PartDocument
oMSDoc = oPartDoc.ComponentDefinition.ModelStates.Item("Model State1").Document
oOcc.Edit
oMSDoc.ComponentDefinition.Features.Item("Extrusion2").Suppressed = True
oOcc.ExitEdit(ExitTypeEnum.kExitToPrevious)
Yes all of those are correct. We're still on inventor 2022..... so i cant access those. You might have better luck actually opening the model state document and changing it there. You can set the document visibility to false.
Dim oAss As AssemblyDocument = ThisApplication.ActiveDocument Dim oOcc As ComponentOccurrence = oAss.ComponentDefinition.Occurrences.Item(4) Dim oPartDoc As PartDocument = oOcc.Definition.Document If oPartDoc.ComponentDefinition.IsModelStateMember Or _ oPartDoc.ComponentDefinition.IsModelStateFactory Then Dim oModelState As String = oPartDoc.ModelStateName ' Dim oPartDoc As PartDocument oPartDoc = ThisApplication.Documents.Open(oPartDoc.FullDocumentName, False) oPartDoc.ComponentDefinition.ModelStates.Item(oModelState).Activate oPartDoc.ComponentDefinition.Features.Item("Extrusion1").Suppressed = False oPartDoc.Save oPartDoc.Close End If oAss.Update