Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Turning lots of features on and off in ilogic

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
josephcooley
1590 Views, 11 Replies

Turning lots of features on and off in ilogic

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

11 REPLIES 11
Message 2 of 12
MjDeck
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
Autodesk, Inc.

Message 3 of 12
josephcooley
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.

Message 4 of 12
MjDeck
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
Autodesk, Inc.

Message 5 of 12
josephcooley
in reply to: josephcooley

Thanks that worked I think.

Message 6 of 12
-ianf-
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 & Vault 2023

Dell 7550 Xeon E-2276M, 2.80Ghz 64GB RAM
Nvidia Quadro RTX 4000
Message 7 of 12
RoyWickrama_RWEI
in reply to: MjDeck

I would also like to locate the EOP using an iLogic code by referring to any sketch or feature name (for example Sketch10) in the browser.

Could you help. Thanks.

 

Greenshot-01.png

Message 8 of 12
MjDeck
in reply to: RoyWickrama_RWEI

I attached a rule that will set the end-of-part marker based on a text parameter.
To use it, create a user text parameter named EndOfPart in your part. Create a new rule and copy in the text.
To run it, change the EndOfPart parameter to either a feature or a sketch name. Or you can change it to "None" or "End" to move the end-of-part to the bottom of the model.


Mike Deck
Software Developer
Autodesk, Inc.

Message 9 of 12
RoyWickrama_RWEI
in reply to: MjDeck

Hi MjDeck;

 

Thanks a lot. It works nicely. I will integrate the code in my set of rules.

 

Also I tested with a little coding shown below:

 

	oLocation_EOP = InputBox("EOP MOVE: ", "TO LOCATE EOP", "Type location for EOP to move")
	Dim endOfPartName As String		' = EndOfPart
	endOfPartName = oLocation_EOP

Roy Wickrama

 

Message 10 of 12
tonythm
in reply to: RoyWickrama_RWEI

Hi Roy Wickrama,

 

Thanks a lot. 

 

With the your code below, what is the value input?  Please explane to me. Thank you.

"Type location for EOP to move"

 

Message 11 of 12
MjDeck
in reply to: tonythm

@tonythm , it is the name of a feature as shown in the model browser.


Mike Deck
Software Developer
Autodesk, Inc.

Message 12 of 12
tonythm
in reply to: MjDeck

Hello,

 

Thank you so much.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report