This is the ipt which I took the rule off.
I hope it is what you want.
Try adding this to the end of your DeleteFeatures sub:
Dim oSketch As PlanarSketch Dim oSketches As PlanarSketches oSketches = oDoc.ComponentDefinition.Sketches For Each oSketch In oSketches If oSketch.Dependents.Count = 0 Then oSketch.Delete Next For Each oSketch In oSketches If oSketch.Dependents.Count = 0 Then oSketch.Delete Next
The reason the first code doesn't clean up all of the sketches is because it only deletes those sketches that are being consumed by the features that are being deleted.
Note that we have to run though all of your skecthes twice. This is because you have interdependencies between sketches and you cannot delete a sketch that has something else dependent on it. I'm playing around with a more elegant way to do this, but this way does work.
It is nice and clean now.
Thanks lot, Mike.
If you come up with a tidier way of doing it can you post it on here please.
The code seems to do it's job for me but gives an error message. Does this happen for you too? I will attach my code
Error in rule: DeleteSuppressedFeatures, in document: DeleteSuppressedFeatures.iLogicVb
Object variable or With block variable not set.
System.NullReferenceException: Object variable or With block variable not set.
at p.b(String A_0)
I can bypass this by using 'On Error Resume Next' but I would rather have a real fix. I am maybe going to be using this code later to write a rule which will seperate ipart members into standard part files.
You have oDoc dimmed as DrawingDocument and you didn't set it equal to anything. If you just replace "oDoc" in my code snippet with "ThisDoc.Document" you should be OK. I'm surprised it still works at all like that.
Are you trying to run this from a drawing?
Thanks for your help Mike,
I just got a bit confussed as I am still getting my head around dimming things (i had coppied that line of code from a program I have that runs in a drawing)
Thank you for posting those rules. They work fine on different features but not on the Coil feature (the sketch is not deleted by the rule) and I am totally puzzled by that...please take a lok at the attached file.
Do you have any idea why? - I would greatly appreciate any response.
I have a simple assembly with supressed parts, I used the code above (2nd post) for the supressed parts, not sure why, but i`m getting a error:
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Can you please help? Is this because I have Patterns with supressed elements?