Supress if no effect

Supress if no effect

ASchlaack
Collaborator Collaborator
1,934 Views
21 Replies
Message 1 of 22

Supress if no effect

ASchlaack
Collaborator
Collaborator

Is there a rule to supress a feature (a cut) if it has no effect?

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Accepted solutions (1)
1,935 Views
21 Replies
Replies (21)
Message 2 of 22

MegaJerk
Collaborator
Collaborator

Usually you’ll want to suppress a feature when the conditions of the part do not require it. In other words, what does a user have to do to the part to make the cut unnecessary? Figuring that out will allow you to create a logical statement that turns it off and on based on those conditions. 

Additionally, a softer (and while occasionally useful, mostly just extra work and file-size) approach could be to use your sketch containing the profile of your cut to first make a Face Feature, and then reuse it to make the desired cut feature. This will ensure that no matter what, the feature will have something to cut through and will not error out even though it is away from the main body of the part. 

To be certain, I have never seen anyone use this method to approach a design (and I’m sure a design guru like JDMathers might have a strong word with me for suggesting that you muck up your model with extra junk), it is a cheap way of working around feature errors in a pinch. 

If you need further help, please post some more part specific information.



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 3 of 22

ASchlaack
Collaborator
Collaborator
That was my first thought to do but this is a complex part that's driven by a few different parameters. And because of them there are times when the sketch losses reference points or ends up erroring itself just to follow the parameters. At the current moment there's about 200 possible models that can be made depending on the varible combinations. So that's why I'd like to have the rule be able to tell when the sketch isn't doing anytihng, if I can't get a rule to do that I'd basically have to write a 200+ case rule that reads a few different parameters.
Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 4 of 22

mrattray
Advisor
Advisor

 

There is a health status property you could check.

Here is a sample where I check the health status of all of my hole features:

 

Public Sub findSickFeatures(doc As PartDocument)

Dim hole As HoleFeature
Dim holes As HoleFeatures


holes = doc.ComponentDefinition.Features.HoleFeatures

For Each hole In holes
    If hole.HealthStatus <> kUpToDateHealth And hole.HealthStatus <> kSuppressedHealth Then
        MsgBox("There's a problem with one of the hole patterns. Check your parameters. Problem feature: " & hole.Name, vbOKOnly, "UnHealthy Feature Detected!")
        Exit Sub
    End If
Next

End Sub

 

Mike (not Matt) Rattray

0 Likes
Message 5 of 22

ASchlaack
Collaborator
Collaborator
That's really cool, thanks. But what would you use to replace "hole" and "HoleFeature" on the second line? I tried just doing "Cut" and "CutFeature" but that didn't work.
Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 6 of 22

ASchlaack
Collaborator
Collaborator

2015-04-29_1436.png

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 7 of 22

MechMachineMan
Advisor
Advisor
Still rocking the For loop in terms of holes.

And also, don't you mean extrusion rather than cut?

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 8 of 22

ASchlaack
Collaborator
Collaborator
No, it's sheet metal so it's a cut.
Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 9 of 22

MegaJerk
Collaborator
Collaborator

Interesting. Is there any chance that you could post the part proper (or a run-down version of it)?



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
0 Likes
Message 10 of 22

ASchlaack
Collaborator
Collaborator

Here's about what the part is. There's a form you can open, change that (or the parameter named "Angle) to 0. Then there will be the cut error. I've also got the rule given above but it doesn't work due to the errors it's getting, also talked about above.

Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 11 of 22

MegaJerk
Collaborator
Collaborator

I finally found some time to look at your part and have re-uploaded it here for you check. Instead of trying to suppress a feature that was in an error state, I instead used a mathematical / logical approach to solving the problem. In fact, here is the code that I used : 

If Angle < 0 Then
	Angle = 0
End If 

If Angle > 90 Then 
	Angle = 90
End If

Feature.IsActive("Cut1") = Angle > 0 And Angle < 90

What's happening there? 

Well first and foremost, I am setting up a minimum and maximum distance that your angle can be. Why? Because going beyond 90 degrees will result in your part being cut into two separate bodies (ew), and everything from 180 ~ 360 (or everything below 0 to -180) is totally unaffected by the cut feature any ways. There's no reason we should let the user input values outside of the 0~90 range, but making a giant table of acceptable ranges is... well... unacceptable. The first two IF/THEN statements keeps our ranges in check. 

The LAST line of code is what turns the feature on / off, but we're being a bit clever about it. Instead of writing an IF/THEN statement, I'm basically saying that the Feature's State will = The outcome of the conditional statement 'Angle > 0 And Angle < 90'  That means that the Feature.IsActive("Cut1") is only true if Angle is Above 0 AND Below 90. If one of those conditions is isn't true (for instance, your angle is 0) then the cut is turned off. 

Here is another way I could have written that 

If Angle > 0 Then 
   If Angle < 90 Then 
      Feature.IsActive("Cut1") = True
    Else 
      Feature.IsActive("Cut1") = False
    End If
Else 
   Feature.IsActive("Cut1") = False
End If 


Pretty big difference huh? 

Now, while I understand that your real-world part may be a lot more complicated than the one you gave me, I highly recommend that you do not give up on approaching this from the same vector I did. Just as you would model a part or assembly with your design intent in mind, you often can use those same constraints to logically configure and manipulate the more dynamic aspects of those same models. 

If you like how simply this problem was solved, but are unsure whether or not you can apply that same simplicity to a more complicated feature set, please do post more things (or through private message), and I will do my best to find a less API heavy way of solving it. 

------


TOTAL SIDE NOTE: When in the hell did Inventor get good at not freaking out when you drove a dimension below 0 using a parameter (or some other math)!? Granted, if you try to open a dim that is below 0, it will still say that it's out of an expected range, but it used to just be a 50:50 chance as to which direction it would go once you increased the value > 0. 

Crazy stuff! 

**** EDIT **** 

Never mind 😞 Further tests show that while it works on the instance of this part (and possibly angles in general), it does not however work for linear dimensions in an expected way 😞 I guess I'll stick to using work geometry offsets as a deterrent. **** it!!!

- The End 




If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 12 of 22

ASchlaack
Collaborator
Collaborator
I get what you're saying and thanks for the help! I guess I'm just going to have to do it the long way and figure out every situation and have it turn on or off by case statement.
Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 13 of 22

ASchlaack
Collaborator
Collaborator
Mike,
Could I please get you to edit this to be for extrusions or cuts please? I'm not skilled enough to do this on my own, I've put in a few attempts but nothing seems to work.
Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 14 of 22

MegaJerk
Collaborator
Collaborator
Like I said, if you need help with making it as simplistic as possible, post your part here and we can work on it.


If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
0 Likes
Message 15 of 22

ASchlaack
Collaborator
Collaborator
Due to the nature of what it is I can't post or share my part. The best I can honestly post is the part I already did.
Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 16 of 22

philippe.leefsma
Alumni
Alumni

It is a CutFeature, see how easily I can find this out using the VBA editor:

http://screencast.com/t/q8yTveaKQrv

 

And the reply using the health status is the correct way to check if a feature has an effect or not.

 

Philippe.

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 17 of 22

ASchlaack
Collaborator
Collaborator
I'm very confued by the link to a screenshot you posted.. What's it showing?
Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes
Message 18 of 22

philippe.leefsma
Alumni
Alumni

Sorry I posted a scrennshot instead of the recording :s

 

Here you go:

http://screencast.com/t/aQN0osPa2Cr

 

It shows how to use VBA and the select set to check what object type in the API represents the selected entity in the UI.

 

Hope that helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 19 of 22

rjay75
Collaborator
Collaborator

Shot gun approach to just check all features.

 

Public Sub findSickFeatures(doc As PartDocument)

Dim feature As PartFeature
Dim features As Features


features = doc.ComponentDefinition.Features

For Each feature In features
    If feature.HealthStatus <> kUpToDateHealth And feature.HealthStatus <> kSuppressedHealth Then
        MsgBox("There's a problem with one of the features. Check your parameters. Problem feature: " & feature.Name, vbOKOnly, "UnHealthy Feature Detected!")
        Exit Sub
    End If
Next

End Sub

If you really only want cuts and extrusions

 

Public Sub findSickFeatures(doc As PartDocument)

Dim feature As PartFeature
Dim features As Features


features = doc.SheetMetalComponentDefinition.Features

For Each feature In features
    If (TypeOf feature Is CutFeature Or TypeOf feature Is ExtrudeFeature) And feature.HealthStatus <> kUpToDateHealth And feature.HealthStatus <> kSuppressedHealth Then
        MsgBox("There's a problem with one of the features. Check your parameters. Problem feature: " & feature.Name, vbOKOnly, "UnHealthy Feature Detected!")
        Exit Sub
    End If
Next

End Sub

 

 

Message 20 of 22

ASchlaack
Collaborator
Collaborator
But if something else errors out then it will change what I only what it to if the one feature errors out. Is there anyway I can just do it for "extrusion3"?
Thanks,
Aaron Schlaack
---------------------------------------------------------------------------------
Autodesk Inventor 2018
Dell Windows 8.1 64 bit Intel(R) Xeon(R) @ 3.50GHz 32GB Ram
0 Likes