- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Supress part feature while edit in place
I'm trying to toggle suppression states of a user selected feature (extrusion) while double clicked into a part (edit in place) from an upper level assembly.
This works if the part is open explicitly but not while editing in place. What am I missing?
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveEditDocument
Dim oParams As Parameters
oParams = oDoc.ComponentDefinition.Parameters
Dim oFeatures As PartFeatures
oFeatures = oDoc.ComponentDefinition.Features
Dim oSelectSet As SelectSet
oSelectSet = oDoc.SelectSet
For Each Feature_Name In oSelectSet
oName = Feature_Name.name
If Feature.IsActive(oName) = False Then
Feature.IsActive(oName) = True
MsgBox("part is off - unsuppress it")
ElseIf Feature.IsActive(oName) = True Then
Feature.IsActive(oName) = False
MsgBox("part is on - suppress it")
Else
End If
Next
InventorVb.DocumentUpdate()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is this iLogic rule a 'local' rule, or an external rule? If it is a local rule, is it saved in the target part file, or in the assembly file? If it is a local rule and saved in the part file, you can set "oDoc = ThisDoc.Document" to ensure it is always referring to that specific part file. If it is local and saved in the assembly, avoid using "ThisDoc", and stick with what you've got, but I would at least include a DocumentType check at the beginning of the rule, and if it's not a Part document, use a MsgBox() or MessageBox.Show() to inform yourself (user) about it, then either "Exit Sub" or "Return".
If it is an external rule, I would also likely stick with your current reference, but also include the document type check at the beginning. You might even try the ThisApplication.ActiveEditObject route, even though that seems less likely.
Also, just inside your loop of the SelectSet, you might want to check what Type of object it is before attempting to use it.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you have time, please... Vote For My IDEAS
or you can Explore My CONTRIBUTIONS
Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Got this working. Here's a little more details on what I'm doing.
The goal is to create a global rule with a button in global forms that:
- In an assembly: Suppress parts or sub-assemblies and corresponding constraints
- In a part: suppress features
- In a drawing: suppress views
This is just a part of the program. I have a main global rule that evaluates the document type and then calls the correct external rule (assembly, part, drawing). The issue was that the rule wouldn't evaluate the correct document while double clicked into a part or sub-assembly (edit in place). Ended up solving this by adding the first "IF" statement. I don't know why this works but it does! Lemme know if you can clue me into the 'why'.
'Set oDoc to active edit document to allow editing of 'edit in place' parts & sub-assemblies
Dim oTest_Doc As Document = ThisApplication.ActiveEditDocument
Dim oDoc As Document
If Not (oTest_Doc Is ThisApplication.ActiveDocument) Then
oDoc = ThisApplication.ActiveDocument
Else
oDoc = ThisDoc.Document
End If
'Set the user selection'
Dim oSelectSet As SelectSet = oDoc.SelectSet
'Toggle parts on or off based upon user selection and current state.
For Each oFeature In oSelectSet
oFeature_Name = oFeature.name
If Feature.IsActive(oFeature_Name) = False Then
Feature.IsActive(oFeature_Name) = True
'MsgBox("part is off - unsuppress it")
ElseIf Feature.IsActive(oFeature_Name) = True Then
Feature.IsActive(oFeature_Name) = False
'MsgBox("part is on - suppress it")
Else
MsgBox("Unable to change feature: " & oFeature_Name)
End If
oMessage = oMessage & " • " & oFeature_Name & vbnewline
Next
'Notify user'
MsgBox ("Changed Suppression States on Parts: " & vbnewline & oMessage)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for the details. I tried to use ThisApplication.ActiveEditObject but was unable to get that working. I'm not sure of the context to use ActiveEditObject, the API help wasn't very helpful with that... at least to me! ![]()