iLogic extrusion turn active or inactive by name

iLogic extrusion turn active or inactive by name

Anonymous
Not applicable
1,740 Views
14 Replies
Message 1 of 15

iLogic extrusion turn active or inactive by name

Anonymous
Not applicable

Hello,
I Need an ilogic rule for my Inventor parts.
Searched the Internet already, but I can not find something what would help me.

What I want is:
I have a part in Inventor and I want to toggle off or on one or more Extrusion.

Example:
Part1:1
Extrusion1 Name (MPK1)
Extrusion2 Name (MPK2)
Extrusion3 Name (MPK3)
Extrusion4 Name (FAC1)

I now want to set MPK1-MPK3 inactive and FAC1 active with ilogic rule.
The Problem is, that there can be only one MPK or more and sometimes no one.
Part1:1
MPK1

FAC1

MPK2

 

Part1:2
MPK1

MPK2

MPK3

 

Part1:3

FAC1

I think of something like "For each Left(Extrusion.Name,3) = MPK"
Anyone who could helpf me?

Sry 4 bad englisch

0 Likes
Accepted solutions (1)
1,741 Views
14 Replies
Replies (14)
Message 2 of 15

Jef_E
Collaborator
Collaborator
Accepted solution

For example you could do loop the features in the part document

 

This code will run from the partdocument level and turn off all extrude features where the name contains MPK.

 

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

For Each oExtrude As ExtrudeFeature In oDoc.ComponentDefinition.Features.ExtrudeFeatures

    If oExtrude.Name.Contains("MPK") Then
        oExtrude.Suppressed = False
    End If

Next

If you need to know how to select documents from the assembly level please let me know.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
Message 3 of 15

Anonymous
Not applicable
Ok, that select the MPK extruded elements, but it doesnt Switch them inactive...

(Yes, it would be helpfull in the future to knew how to select Level of assembly)
0 Likes
Message 4 of 15

Anonymous
Not applicable
Ok. Works. I didnt realised that it have to be "true"
0 Likes
Message 5 of 15

Jef_E
Collaborator
Collaborator

Do you want this code to run from the assembly level for all documents that are in the assembly? Or do you want to select them by name? Or select them by mouse? I need a little information about this.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 6 of 15

Anonymous
Not applicable
Select by Mouse is most of time standard.
Sometimes I need name. I use it in different ilogic rules.

For all never.

Thanks for your help so far. 🙂
0 Likes
Message 7 of 15

Jef_E
Collaborator
Collaborator

Here is a code where you need to select some objects and then run the code.

I commented the code so it's easier for you to understand.

 

' Get the active document object
' Code assumes that the active document
' an assembly document. When ran from a
' part document an error will occur
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument

' Get the select set object
' this hold all selected entities
Dim oSelectSet As SelectSet
oSelectSet = oAsmDoc.SelectSet

' Show the number of entities selected.
' these entities can be anything from
' a part to a workplane, all will be counted.
MsgBox("Selected item count = " & oSelectSet.Count)

' Loop all selected items
For Each oOccurrence As ComponentOccurrence In oSelectSet
	
	' Check if a part document is selected else
	' Process the next occurrence
	If Not oOccurrence.Definition.type = kPartComponentDefinitionObject Then
		Continue For
	End If
	
	' Get the occurrence definintion
	Dim oDef As PartComponentDefinition
	oDef = oOccurrence.Definition

	' Loop all extrude features in the part.
	' If there are none, the loop will not do anything
	For Each oExtrude As ExtrudeFeature In oDef.Features.ExtrudeFeatures 
		
		' Check if the name of the extrude feature
		' contains suppied string
		If oExtrude.Name.Contains("MPK") Then
		
			' change the extrude feature suppression state
			' True = suppressed
			' False = unsuppressed
			oExtrude.Suppressed = False
		End If
	
	Next

Next


Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
Message 8 of 15

Anonymous
Not applicable
Thank you for your help! 🙂
That will help me alot.
0 Likes
Message 9 of 15

Anonymous
Not applicable

Hello,
one question to the last code.
How can I select a part (element) of an assembly with it?

I added the code, the selected parts are counted, but nothing happens after it.

0 Likes
Message 10 of 15

Jef_E
Collaborator
Collaborator

I don't understand nothing happens? If nothing happens the value for the extrude suppressed is the same and nothing is changed?



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 11 of 15

Anonymous
Not applicable

I try to explain what I mean.

I have an assembly with more then one part inside.
I select the part.
The code is original. Nothing is changed.

The part is counted and the msg box show "1" counted.
But the Extrusion isnt set to suppressed or unsuppressed.

The screenshot are a very simple assembly as test. I want to select "Part 2" in example.
And if selected, I want to run the rule for the selected part.


As Information:
I use the code in global ilogic rules and as you can see, it is a multibodypart.

0 Likes
Message 12 of 15

Jef_E
Collaborator
Collaborator

@Anonymous wrote:


The code is original. Nothing is changed.


Well off-course this will not work.. The code sample I gave you just sets the extrusion off. I will NEVER turn it on. Do you want it to detect if it's off, and set it on then? Do you want to set all on and off by user choice when the rule runs?

 

You will need to be more specific to the conditions when what should happen.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 13 of 15

Anonymous
Not applicable

Hey,
thank you for your help.

I have an assembly.
The assembly have two or more aluminium parts with extrusions.
I need the option to exklude the extrusions from my assembly for some other assemblys.

What I have done is, that I have made a macro button with the vba. The button toggle on or off the extrusions.
But I have to open the parts. Each for its own.

What I want ist to select one or more parts in an assembly and extrusions in the selected parts are turned off, where name is "MPK".
And if I pressed the button again, alle the extrusions of selected parts are turned on, where name is "MPK".

 

0 Likes
Message 14 of 15

pbeer
Explorer
Explorer
Ich würde versuchen das mit i-Parts und i-Assembly zu lösen.
Das ist sich sicherer.
Und auch in späteren Versionen kriegst Du keine Probleme.
______________________________________________________
Ihr fandet einen Beitrag hilfreich? Dann vergebt dafür doch Kudos!
Eure Frage wurde erfolgreich gelöst? Dann einfach auf den 'Als Lösung akzeptieren'-Button klicken!


Philip Beer
0 Likes
Message 15 of 15

Anonymous
Not applicable
Hallo pbeer,
das geht leider schlecht, weil wir hier so ca 20 verschiedene Extrusionen haben und damit verschiedenste Kombinationen erstellen.
Bisher habe ich keinen Weg gefunden, das in iAssembly umzusetzen, ohne diese Versionen alle anlegen zu müssen.
Das Problem ist, dass ich im iAssembly keine Benutzerdefinierte Version erstellen kann.
Und dann fehlt mir eine vernünftige Oberfläche. Da wir das ganze hier hinterher einfachen Mitarbeitern zur Verfügung stellen, die mittels einer ganz einfachen Oberfläche die Extrusionen auswählen und die Baugruppe hinterher selbst für die Maschine ablegen.

Daher löse ich das im Moment damit, dass wir ein Formular erstellen und iLogic nutzen.
0 Likes