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 commands for adding a participant to a cut..

21 REPLIES 21
Reply
Message 1 of 22
Anonymous
3048 Views, 21 Replies

iLogic commands for adding a participant to a cut..

Hi guys,

 

I have a pattern that patterns a number of wall panels into a room, depending on the width of the room.. I have a cut that runs along the top to take the slope of the room that cuts the panels to the height of the room at various points.

 

When i change the width, the number of components in the pattern change, but the cut will ignore them until I add participant manually.. I dont want to do this manually.

 

I have trawled the net but to no avail.. Can anyone help with this??

 

Thanks 

Mike

21 REPLIES 21
Message 2 of 22
stephanbotes
in reply to: Anonymous

i am currently having a very similiar issue with crossmembers in a structure that require holes for a conduit. The crossmembers are part of a changing rectangular pattern. as the pattern is changed new members are not included in the extrusions forming the holes. i have figured out how to address the individual members of the pattern but cant seem to figure out how to make them participate in the weldment preparation...

 

attached is a picture of the crossmembers with the sweep forming the holes highlighted

Message 3 of 22
ad64
in reply to: stephanbotes

I'm also interested in knowing the answer to this question.

Steve
Message 4 of 22
mrattray
in reply to: ad64

These sort of questions tend to get a better response when posted here: Inventor Customization.

Mike (not Matt) Rattray

Message 5 of 22
MegaJerk
in reply to: Anonymous

I’m not really certain what you’re attempting to describe in your scenario. Could you provide a screenshot (or screenshots) detailing what it is you’d like to accomplish, what is going wrong, and what you do to fix it?

As for Stephanbotes, who did include a screenshot (though it does not seem to show any patterns in the browser :-/) it looks as if you could save yourself the trouble of having two patterns, by simply moving those cuts to the part models themselves. If the cuts become part of the part model, then you won’t have to worry about keeping the quantities of the patterns in check and save yourself a little time.

All in all, using iLogic to add members to a pattern probably isn’t what would actually helpful. Altering how your patterns are being made, or adding in a parameter (containing a formula for member quantity calculation), or even simply reusing a parameter that has been made available from the pattern you’d like to base your cuts on all seem like the direction that should be looked at.

Please post more information and any part / assembly files that you can. If they are 2012 or lower, I can look at them sooner. If not, please post the version that you’re using and I, or somebody else, will look at them later ;).




If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 6 of 22

Hi everyone,

 

As I understand it, the request is to automate the process with which we add and assembly feature participants, as described at these links:

http://help.autodesk.com/view/INVNTOR/2015/ENU/?guid=GUID-967D97A2-C508-4B16-850F-F5A05637BB0B

http://www.inventortales.com/2014/01/controlling-component-participation-in.html

http://inventortrenches.blogspot.com/2011/05/isolate-before-assembly-features.html

 

I did a quick search, but did not find anything in the API that exposes this ability. I might have missed it though.

 

I did just find this Control Definition command:

AssemblyAddFeatureParticipantCtxCmd

 

If I can come up with a working example I'll post back later.

 

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

Message 7 of 22

 

Hi everyone,

 

A bit more digging turned up some more information in the API. Here's an example that is looking for an assembly feature named "Extrusion 1", and an assembly component occurence named "Arbor_Frame:1". Change the names to fit your needs in order to see it in action.

 

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

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmDoc= ThisApplication.ActiveDocument

Dim oDef As AssemblyComponentDefinition
oDef = oAsmDoc.ComponentDefinition

Dim oAssemblyFeatures As Features
oAssemblyFeatures = oDef.Features

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oDef.Occurrences
    If oOccurrence.Name = "Arbor_Frame:1" Then
    oOcc = oOccurrence
    Else
    End If
Next

Dim oAssemblyFeature As PartFeature
'Iterate through all of the assembly features
For Each oAssemblyFeature In oAssemblyFeatures
    If oAssemblyFeature.Name  = "Extrusion 1" Then
    'add the occurrence to the feature
    oAssemblyFeature.AddParticipant(oOcc)
    Else
    End If
Next

 

Message 8 of 22

Hi everyone,

 

Here is another example that adds all of the components of a pattern called "Component Pattern 1:1" to the assembly feature called "Extrusion 1".

 

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

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmDoc= ThisApplication.ActiveDocument

Dim oDef As AssemblyComponentDefinition
oDef = oAsmDoc.ComponentDefinition

Dim oPat As OccurrencePattern
oPat = oDef.OccurrencePatterns.Item("Component Pattern 1:1") 

Dim oAssemblyFeatures As Features
oAssemblyFeatures = oDef.Features

Dim oAssemblyFeature As PartFeature
'Iterate through all of the assembly features
For Each oAssemblyFeature In oAssemblyFeatures
    If oAssemblyFeature.Name  = "Extrusion 1" Then
   	'look at the pattern elements
   	 Dim oPatE As OccurrencePatternElement
	For Each oPatE In oPat.OccurrencePatternElements
		'look at the pattern element contents
		Dim oOcc As ComponentOccurrence
		For Each oOcc In oPatE.Occurrences
		 'add the element contents to the feature
		 oAssemblyFeature.AddParticipant(oOcc)
		Next
	Next
    End If
Next

 

Message 9 of 22

After Curtis had initially posted and I started to understand what the problem was, my brain started to get an idea on how to maybe fix it. However, due to work and other obnoxious things such as lava arrows / laser swords, I was unable to write anything up and my brain was left yearning. It would also now seem that Curtis has provided not one but TWO (!) super keen suggestions that may or may not fix the problem all of you are having.


Despite that, I have finally found a little time to get this stuff out of my brain and have attached a file of the resulting iLogic code. While it does an alright job of accomplishing the task at hand (adding missing participants), I feel like the dynamic nature of it may be a good starting point for someone else to come along and do something more with it in the later days if they so choose. Just remember that this will only add participants already added into a Pattern, and will ignore everything else! 

Remember to save your work before you try it 😉 

PS: I didn't comment any of my code because A) It's midnight & B) I'm a jerk.




 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 10 of 22
ad64
in reply to: Curtis_Waguespack

When I tried using Curtis' code as iLogic code in an existing assembly, I received this error "The parameter is incorrect." What kind of problem does this error message usually indicate? I've seen it often before in other code.

 

The line  that throws the error is: oAssemblyFeature.AddParticipant(oOcc)

 

I've message boxed both oAssemblyFeature.Name and oOcc.Name to confirm that oAssemblyFeature is referencing a real feature in my assembly and oOcc is a real occurrence in my assembly. Both of them are, so I'm not sure what is producing the error.

 

Steve

Message 11 of 22
MegaJerk
in reply to: ad64

Curtis posted two code solutions. Are you having trouble with both of them?

Also, try the iLogic attached to the text file in my post above and see if it might work. 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 12 of 22
stephanbotes
in reply to: MegaJerk

Firstly I want to thank everyone for their contributions to the thread. You guys have been really helpful.

 

Secondly I have code below that solves my original question (at least for me)

Sub jchannelSweepParticipationAdder(ByVal oOcc As ComponentOccurrence,ByVal oSweep As SweepFeature)

Dim oSubOccProxy As ComponentOccurrenceProxy
oOcc.CreateGeometryProxy (oOcc.SubOccurrences(1), oSubOccProxy)

oSweep.AddParticipant (oSubOccProxy) 

End Sub

 The sub allows one to add members of a variable sized occurence pattern to a sweep feature in the parent assembly. It seems like a big part of the issue was the inability to include the subassemblies in the occurence pattern in the sweep feature. This is fixed by creating proxies of the subassemblies that can then be added to the sweep feature.

 

While this by and large solves the problem it is not yet perfect as it works well within the assembly where the rule resides but throws the "invalid parameter" error when the assembly containing the rule is included in another assembly and the rule is then triggered from the new parent assembly. I am not entirely sure what causes this behaviour as the rule still seems to execute correctly despite the error.(so im just kind of living with it right now)

Message 13 of 22
stephanbotes
in reply to: MegaJerk

the reason moving the cuts to the parts themselves is not an effective solution is that the spacing of the occurrence pattern changes dynamically based on a variety of constraints. as such the intersection of the sweep feature and the individual parts varies significantly. (in fact that is kind of the whole point of this is to avoid having to individually design the members of the pattern and rather have the them created in the parent assembly driven by the constraints in the parent assembly)
Message 14 of 22
ad64
in reply to: stephanbotes

I was able to develop an iLogic routine to add all the relevant participants to the cut whenver the iAssembly row changed and the components changed using Table Replace. That works fine in the model, but it's not help for creating drawings of al the different states for this reason: When I manually change rows, the iLogic routine runs; but if I use "Generate Files" then it does not run the routine before saving the generated files. So in the end, only the iAssembly row that was last active gets the extruded feature. And the others are not participants because their iParts were absent form the assembly when the file was saved. 

 

I wish there was a way to set assembly features to always contain all active parts in the assembly without having to manually add or remove participants. That would solve my problem altogether.

 

Steve

Message 15 of 22
stephanbotes
in reply to: ad64

the way that I have managed to get it to work despite the errors is to simply run the code before and after save which requires the whole assembly to be updated and saved twice.

That being said that is a rather crude solution. I would also agree that at least from my humble perspective the problem would readily be solved by including everything in the feature automatically (maybe with the ability to explicitly exclude certain subassemblies).

Message 16 of 22
Nauld1
in reply to: Curtis_Waguespack

So I wanted to use this to add only 2 different participants to the cut, is this possible?

Message 17 of 22
Curtis_Waguespack
in reply to: Nauld1

 


@Nauld1 wrote:

So I wanted to use this to add only 2 different participants to the cut, is this possible?


Hi Nauld1,

 

Here is a quick example.

 

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

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmDoc = ThisApplication.ActiveDocument

Dim oDef As AssemblyComponentDefinition
oDef = oAsmDoc.ComponentDefinition

Dim oAssemblyFeatures As Features
oAssemblyFeatures = oDef.Features

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oDef.Occurrences
    If oOccurrence.Name = "MTG SIDE:1" Then
    	oOcc1 = oOccurrence 
    ElseIf oOccurrence.Name = "MTG SIDE:2" Then
    	oOcc2 = oOccurrence 
    End If
Next

Dim oAssemblyFeature As PartFeature
'Iterate through all of the assembly features
For Each oAssemblyFeature In oAssemblyFeatures
    If oAssemblyFeature.Name  = "Extrusion 1" Then
    	'add the occurrences to the feature
    	oAssemblyFeature.AddParticipant(oOcc1)
    	oAssemblyFeature.AddParticipant(oOcc2)
    End If
Next
Message 18 of 22
iogurt1
in reply to: Curtis_Waguespack

We are attempting to make this code work for a pattern within a pattern. So far we've come up with the following but it gives us a "The parameter is incorrect" error:

 

SyntaxEditor Code Snippet

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmDoc= ThisApplication.ActiveDocument

Dim oDef As AssemblyComponentDefinition
oDef = oAsmDoc.ComponentDefinition

Dim oPat As OccurrencePattern
oPat = oDef.OccurrencePatterns.Item("Component Pattern 1:1") 

Dim oAssemblyFeatures As Features
oAssemblyFeatures = oDef.Features

Dim oAssemblyFeature As PartFeature
'Iterate through all of the assembly features
For Each oAssemblyFeature In oAssemblyFeatures
    If oAssemblyFeature.Name  = "Extrusion 1" Then
       'look at the pattern elements
        Dim oPatE As OccurrencePatternElement
    For Each oPatE In oPat.OccurrencePatternElements
        'look at the pattern element contents
        Try 'New code starts here
            Dim oPat2 As OccurrencePattern
            oPat2 = oDef.OccurrencePatterns.This
            Dim oPatE2 As OccurrencePatternElement
            For Each oPatE2 in oPat2.OccurrencePatternElements
                                    'back to Curtis' code until end try
                                    Dim oOcc As ComponentOccurrence
                                    For Each oOcc In oPatE2.Occurrences
                                    'add the element contents to the feature
                                    oAssemblyFeature.AddParticipant(oOcc)
                                    Next
            Next
        Catch
        End Try
    Next
    End If
Next

 

Message 19 of 22
mizo303
in reply to: Curtis_Waguespack

Hi all ,

 

i would like to know if its possible to get only a range of element to add as a participant occ.

 

for example :

 

i have a skeleton where i position a rectangural sketch 

i only want to let involve the participants according the sketch width.

 

 

Thx in advance !

 

 

 

Message 20 of 22
Breeze104
in reply to: MegaJerk

I know this is an old post, but it is relevant to what I am working on.  I am trying to in corporate the code (.txt file you provided) but I don't see where I can substitute my parameters/variables into the code.  Could you please give some incite as to what I am missing?

 

PS

I am not a super coder as yourself, so please be gentle.  

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

Post to forums  

Autodesk Design & Make Report