Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic FOR loop to unsupress features

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
rasmuscalundann
8493 Views, 13 Replies

iLogic FOR loop to unsupress features

Hi, I am currently designing a heat exchanger and want to adjust the number of water channel using iLogic. The number of channels to be active is based on the channel dimensions, and is calculated in my excel spreadsheet, but up to a maximum of 19. This is stored in the parameter "no_channel". Each channel is a seperate feature (extrusion) and named from "Channel 1" though "Channel 19".

 

My idea of doing this automation was to have iLogic suppress all the features, and then doing a closed loop to unsuppres the features I want active:

 

Feature.IsActive("Channel 1") = False
Feature.IsActive("Channel 2") = False

.
.
.

Feature.IsActive("Channel 19") = False

For i = 1 To no_channel
Feature.IsActive("Channel"(i)) = True
Next

 

However, this gives me the following error:

 

Error in rule: Number of channels, in document: Radiator fin side.ipt

Feature.IsActive: No feature found with the name: "h".

 

I am not experienced with iLogic at all, so any help as well as suggestions on improving the efficieny of my automation would be appreciated (eg. having all features active and simply suppressing the unwanted channels).

 

Best regards

13 REPLIES 13
Message 2 of 14

Try this. When i = 1, "Channel "& i returns "Channel 1"

Feature.IsActive("Channel "& i) = True
Message 3 of 14

Awesome, that did it!
Thanks a lot.
Message 4 of 14
Reza.Deabae
in reply to: jianbinlin


@jianbinlin wrote:

Try this. When i = 1, "Channel "& i returns "Channel 1"

Feature.IsActive("Channel "& i) = True

thank you Jianbinlin  for this great tip, i have also a question!

what if we have 2 identifiers in the  name for example if the name of component is like this " Solid:3-2"  and we have tow variables like "i" and "j" and we would like to change the components state within tow "for" loops ??? 

 

the code below did not worked with this configuration because inventor considers "dash" as subtraction sign. i have also tried to change dash sign to UnderLine but not worked. in this case aslo, "i_j" was not correct expression.

so... how should i write this code??

for i=1 to 5
for j=2 to 3
Component.IsActive("Solid:"& i-j) = False
next
next 

Regards

Reza

Message 5 of 14

Try this 🙂

 

For i = 1 to 5
    For j = 2 to 3
        Component.IsActive("Solid:"& i & "-" & j) = False
    Next
Next

This should resolve from

Solid:1-2

to

Solid:5-3

 

===================================================================

=============================================
Autodesk® Inventor® 2019
Autodesk® Plant3D 2019
Message 6 of 14
forbillian
in reply to: jianbinlin

I am trying to search for a method to isolate/split common text/prefix instead of an index value, from a feature name so I can suppress

all features with that same prefix text. See below.

 

Feature Names e.g's:

 

"PREFIX SOMETHIING"

"PREFIX SOMETHING ELSE"

"PREFIX SOMETHING ELSE AGAIN"

"EXTRUDE1"

"EXTRUDE2"

 

SyntaxEditor Code Snippet

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

Dim oFeatures As PartFeatures
oFeatures = oDoc.ComponentDefinition.Features


Dim oFeature As PartFeature


For Each oFeature In oFeatures
    If oFeature.Name.Contains("PREFIX") Then
       Feature.IsActive("not sure what to put in here?") = False
    End If
Next

 

I can't seem to manipulate the "Feature.IsActive()" syntax to apply to only the features that contain the text "PREFIX"?

 

Any help would be greatly appreciated.

Message 7 of 14
Reza.Deabae
in reply to: forbillian

on my opinion, if your "if" statement is true programmatically, you do not need to place any especial command there. and it will be executed as well. but actually I am not sure that the below snippet is true or not. 

oFeature.Name.Contains("PREFIX")

 

Message 8 of 14
forbillian
in reply to: Reza.Deabae

Thanks for the quick response Reza! 

 

The Feature.Name.Contains("PREFIX") is a simpler method of extracting the common text which

appears in the Features I want to isolate and suppress. The other method is using the trim function: Left( Feature.Name,6) = "PREFIX"

 

BUT...................YES you are absolutely right, I don't need that condition to then suppress a named feature.

 

 

But I do want to achieve the same name split of the text as I have done in the ABOVE EXAMPLE

but using this code snippet "Feature.IsActive("featurename") = False" to get my result.

 

I somehow need the ("featurename") in the above snippet to represent any feature.name that contains the text "PREFIX".

 

Apologies if I am not explaining it well, but I am simply trying to avoid having to

specify every feature name in full that I want to toggle the suppression on

 

E.g.

 

Feature.IsActive("PREFIX - FEATURE SIDE") = False"

Feature.IsActive("PREFIX - FEATURE TOP") = False"

Feature.IsActive("PREFIX - FEATURE RHS") = False"

Feature.IsActive("PREFIX - FEATURE LHS") = False"

 

 

 

Hope this clarifies what I am trying to achieve.

 

 

 

 

 

Message 9 of 14

Hi, if you can send me the inventor part I will have a look
=============================================
Autodesk® Inventor® 2019
Autodesk® Plant3D 2019
Message 10 of 14

Hi, if you can send me the inventor part I will have a look
=============================================
Autodesk® Inventor® 2019
Autodesk® Plant3D 2019
Message 11 of 14

Find attached a part with Rule example that suppresses Features when each name is specified.

 

I believe you understand what I am trying to achieve.

 

Thanks in advance for your time on this. Much appreciated.

 

Cheers

Forbillian

 

Message 12 of 14

Hey Robert.

 

I found a solution based on this code I found in an article titled:        'Suppressing all chamfer or fillets with iLogic' By Xiaodong Liang

http://adndevblog.typepad.com/manufacturing/2014/03/subspressing-all-chamfer-or-fillets-with-ilogic....

 

 

SyntaxEditor Code Snippet

doc = ThisDoc.Document
oDef = doc.ComponentDefinition
 
Dim oEachF As PartFeature

For Each oEachF In oDef.Features
    If oEachF.Name.Contains("PREFIX") Then
        oEachF.Suppressed = True
    End If
Next

  See attached part which shows the example & includes another option of text within a different feature name.

 

 

Just want to shout out my appreciation to Robertlee Wheatley for your rapid responses and your time and inspiring me 

to find a solution.  If you have any other suggestions on this scenario please feel free to let us know.

Message 13 of 14
balkeev.tim
in reply to: forbillian

and how to do the same but from the assembly

Message 14 of 14

Hi @balkeev.tim 

 

See this example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

' Get the active document. 
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)
	oDoc = oOccurrence.Definition.Document

	oDef = oDoc.ComponentDefinition

	Dim oEachF As PartFeature

	For Each oEachF In oDef.Features
		If oEachF.Name.Contains("Fillet") Then
			oEachF.Suppressed = True
		End If
	Next
Next

 

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

Post to forums  

Autodesk Design & Make Report