Inventor General

Reply
*Expert Elite*
mrattray
Posts: 2,450
Registered: ‎09-13-2011
Message 11 of 20 (490 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 11:48 AM in reply to: zdhrichard

Can you post a version without the code having been ran?

Mike (not Matt) Rattray

Distinguished Contributor
zdhrichard
Posts: 120
Registered: ‎05-03-2011
Message 12 of 20 (485 Views)

Re: How to delete suppressed components by iLogic Rule

01-24-2013 11:59 AM in reply to: mrattray

This is the ipt which I took the rule off.

 

I hope it is what you want.

Rich

Autodesk Inventor Professional 2013 (64 Bit) SP2
Windows 7 Professional Service Pack 1
Intel(R) Xeon(R) CPU E5645
12.0 GB Memory
*Expert Elite*
mrattray
Posts: 2,450
Registered: ‎09-13-2011
Message 13 of 20 (469 Views)

Re: How to delete suppressed components by iLogic Rule

01-25-2013 05:20 AM in reply to: zdhrichard

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.

Mike (not Matt) Rattray

Distinguished Contributor
zdhrichard
Posts: 120
Registered: ‎05-03-2011
Message 14 of 20 (464 Views)

Re: How to delete suppressed components by iLogic Rule

01-25-2013 05:51 AM in reply to: mrattray

Great.

It is nice and clean now.

 

Thanks lot, Mike.

Rich

Autodesk Inventor Professional 2013 (64 Bit) SP2
Windows 7 Professional Service Pack 1
Intel(R) Xeon(R) CPU E5645
12.0 GB Memory
Valued Contributor
waynehelley
Posts: 99
Registered: ‎09-10-2012
Message 15 of 20 (459 Views)

Re: How to delete suppressed components by iLogic Rule

01-25-2013 06:08 AM in reply to: mrattray

Thanks 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 Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)

   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)

   at LmiRuleScript.Main()

   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

   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.

 

Thanks,

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2013
Windows 7 Enterprise, 64-bit
*Expert Elite*
mrattray
Posts: 2,450
Registered: ‎09-13-2011
Message 16 of 20 (453 Views)

Re: How to delete suppressed components by iLogic Rule

01-25-2013 06:14 AM in reply to: waynehelley

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?

Mike (not Matt) Rattray

Valued Contributor
waynehelley
Posts: 99
Registered: ‎09-10-2012
Message 17 of 20 (450 Views)

Re: How to delete suppressed components by iLogic Rule

01-25-2013 06:26 AM in reply to: mrattray

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)

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2013
Windows 7 Enterprise, 64-bit
Contributor
AERE
Posts: 16
Registered: ‎04-18-2012
Message 18 of 20 (264 Views)

Re: How to delete suppressed components by iLogic Rule

09-13-2013 11:18 AM in reply to: mrattray

Hi Mike,

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.

 

*Expert Elite*
mrattray
Posts: 2,450
Registered: ‎09-13-2011
Message 19 of 20 (261 Views)

Re: How to delete suppressed components by iLogic Rule

09-13-2013 11:37 AM in reply to: AERE
I can't look at it right now as I'm working in 2013 and that's a 2014 file. If I have some free time next week I'll take a look at it.
Mike (not Matt) Rattray

Distinguished Contributor
achmidt
Posts: 130
Registered: ‎07-21-2011
Message 20 of 20 (225 Views)

Re: How to delete suppressed components by iLogic Rule

09-18-2013 09:07 PM in reply to: mrattray

Hi Mike,

 

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 Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
   at LmiRuleScript.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Can you please help? Is this because I have Patterns with supressed elements?

 

 

Thank you

Inventor Virtual Parts Addin

http://apps.exchange.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3Avirtualpartsadd-in_windows32and64%3Aen

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube