Inventor General Discussion

Inventor General Discussion

Reply
Valued Contributor
josephcooley
Posts: 56
Registered: ‎09-25-2009
Message 1 of 6 (506 Views)
Accepted Solution

Turning lots of features on and off in ilogic

506 Views, 5 Replies
10-06-2010 08:39 AM

Is there a better way to turn alot of features on and off than haveing it turn them on and off for each case?  I have put the code but this takes a while to process and I was wondering if there was a faster way to make this happen than markign each one for being turned on or turned off.  I am using 2011 and this is ilogic for a multi body solid that will be made into an assembly later.

 

'EFFLUENT RULES FOR TURNING FEATURES ON AND OFF
If EffluentType="Drop Pipe" Then
    Feature.IsActive("DropPipeFlange")=True
    Feature.IsActive("DropPipeEndRim")=True
    Feature.IsActive("DropPipeExtrusion")=True
    Feature.IsActive("DropPipeCut")=True
    Feature.IsActive("DropPipeChannelEnd")=True
    Feature.IsActive("EffluentChannelRim")=False
    Feature.IsActive("PipedEffluentTrim")=False
    Feature.IsActive("PipedEffluentFill")=False
    Feature.IsActive("PipedEffluentPipe")=False
    Feature.IsActive("PipedEffluentFlange")=False
    Feature.IsActive("PipedEffluentCut")=False
    Drop = iFeature.FindRow("DropPipeFlange", "PipeDiameter", "=", EffluentPipeDiameter)'Change iFeature Flange size
    iFeature.ChangeRow("DropPipeFlange", Drop)

ElseIf EffluentType="Channel" Then
    Feature.IsActive("DropPipeFlange")=False
    Feature.IsActive("DropPipeExtrusion")=False
    Feature.IsActive("DropPipeCut")=False
    Feature.IsActive("DropPipeChannelEnd")=False
    Feature.IsActive("EffluentChannelRim")=True
    Feature.IsActive("DropPipeEndRim")=False
    Feature.IsActive("PipedEffluentTrim")=False
    Feature.IsActive("PipedEffluentFill")=False
    Feature.IsActive("PipedEffluentPipe")=False
    Feature.IsActive("PipedEffluentFlange")=False
    Feature.IsActive("PipedEffluentCut")=False

ElseIf EffluentType="Pipe" Then
    Feature.IsActive("DropPipeFlange")=False
    Feature.IsActive("DropPipeExtrusion")=False
    Feature.IsActive("DropPipeCut")=False
    Feature.IsActive("DropPipeChannelEnd")=False
    Feature.IsActive("EffluentChannelRim")=False
    Feature.IsActive("DropPipeEndRim")=False
    Feature.IsActive("PipedEffluentTrim")=True
    Feature.IsActive("PipedEffluentFill")=True
    Feature.IsActive("PipedEffluentPipe")=True
    Feature.IsActive("PipedEffluentFlange")=True
    Feature.IsActive("PipedEffluentCut")=True
    Piped = iFeature.FindRow("PipedEffluentFlange", "PipeDiameter", "=", EffluentPipeDiameter)'Change iFeature Flange size
    iFeature.ChangeRow("PipedEffluentFlange", Piped)
End If

Every call to Feature.IsActive will do an Update, so it can be slow.  As a workaround, you can have the rule set the end-of-part marker to the top of the model tree.  The part will be temporarily empty, and updates will be fast.  Add this to the top of your rule:

DipartDoc as PartDocument = ThisDoc.Document
partDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(True)' Set to top

 

Dim partDoc as PartDocument = ThisDoc.Document
partDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(True)' Set to top

And add this at the bottom:

 

partDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(False) ' Set to bottom

 

If you need more control over the end-of-part, there is a way to move it before or after a particular feature.

 

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 2 of 6 (501 Views)

Re: Turning lots of features on and off in ilogic

10-06-2010 09:09 AM in reply to: josephcooley

Every call to Feature.IsActive will do an Update, so it can be slow.  As a workaround, you can have the rule set the end-of-part marker to the top of the model tree.  The part will be temporarily empty, and updates will be fast.  Add this to the top of your rule:

DipartDoc as PartDocument = ThisDoc.Document
partDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(True)' Set to top

 

Dim partDoc as PartDocument = ThisDoc.Document
partDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(True)' Set to top

And add this at the bottom:

 

partDoc.ComponentDefinition.SetEndOfPartToTopOrBottom(False) ' Set to bottom

 

If you need more control over the end-of-part, there is a way to move it before or after a particular feature.

 



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Valued Contributor
josephcooley
Posts: 56
Registered: ‎09-25-2009
Message 3 of 6 (498 Views)

Re: Turning lots of features on and off in ilogic

10-06-2010 09:29 AM in reply to: MjDeck

the colors of all that text is brown (like its incorrect maybe)  Should it be purple like the rest of the commands?

ThisDoc.Document is purple and Dim is red  I just wanted to make sure this is correct the rule closes and like there is no syntax error but I wanted to make sure there was no error.

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 4 of 6 (494 Views)

Re: Turning lots of features on and off in ilogic

10-06-2010 09:37 AM in reply to: josephcooley

Those colors sound OK.  Most of that code is Inventor API code (not iLogic functions), so iLogic doesn't show it in purple.  Dim shows up in red because it is a Visual Basic keyword.



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Valued Contributor
josephcooley
Posts: 56
Registered: ‎09-25-2009
Message 5 of 6 (488 Views)

Re: Turning lots of features on and off in ilogic

10-06-2010 09:40 AM in reply to: josephcooley

Thanks that worked I think.

Active Contributor
-ianf-
Posts: 28
Registered: ‎01-07-2010
Message 6 of 6 (198 Views)

Re: Turning lots of features on and off in ilogic

11-15-2012 06:20 AM in reply to: MjDeck

I think moving the End Of Part could be useful for a rule I am setting up. How do you go about writing a command to specify where to move the EOP to?

Sorry for jumping into an old thread.

 

 

Ian Farmery
Inventor 2010 Pro SP4, Vault Collaboration 2010
HP Z820 Xeon E5-2643 0 @ 3.3Ghz 16.0GB RAM
Nvidia Quadro 5000
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.