• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    *Expert Elite*
    mrattray
    Posts: 1,469
    Registered: ‎09-13-2011

    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

    Please use plain text.
    Valued Contributor
    zdhrichard
    Posts: 100
    Registered: ‎05-03-2011

    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.

    Richard Z.

    Autodesk Inventor Professional 2013 (64 Bit) SP1.1
    Windows 7 Professional Service Pack 1
    Intel(R) Xeon(R) CPU E5645
    12.0 GB Memory
    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,469
    Registered: ‎09-13-2011

    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

    Please use plain text.
    Valued Contributor
    zdhrichard
    Posts: 100
    Registered: ‎05-03-2011

    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.

    Richard Z.

    Autodesk Inventor Professional 2013 (64 Bit) SP1.1
    Windows 7 Professional Service Pack 1
    Intel(R) Xeon(R) CPU E5645
    12.0 GB Memory
    Please use plain text.
    Valued Contributor
    Posts: 94
    Registered: ‎09-10-2012

    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 2011
    Windows 7 Enterprise, 64-bit
    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,469
    Registered: ‎09-13-2011

    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

    Please use plain text.
    Valued Contributor
    Posts: 94
    Registered: ‎09-10-2012

    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 2011
    Windows 7 Enterprise, 64-bit
    Please use plain text.