iassembly members active/inactive

iassembly members active/inactive

parth_moradiya
Contributor Contributor
506 Views
6 Replies
Message 1 of 7

iassembly members active/inactive

parth_moradiya
Contributor
Contributor

I have an iassembly master file which has 14 members. I have inserted two user parameters from that I need to configure my assembly. While writing code in ilogic what should I write to visible whole member of iassembly? for example. if one condition is satisfied then, member-01 should true or active like. I want to show something like this.

0 Likes
Accepted solutions (1)
507 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

Hi @parth_moradiya.  I do not know what level of iLogic coding knowledge you may already have, so I will just point out some links to online help documentation for a couple Inventor API coding objects / properties that will likely be important to the task you mentioned below for now.  You will need to access the main AssemblyDocument object, then step through its ComponentDefinition property to get its AssemblyComponentDefinition object, then step through its properties.  It has a property named IsiAssemblyFactory and one named IsiAssemblyMember that you can check, to make sure which type it is (if either).  Then if it is one of them, you can use its other similar properties to get the next object you will need to be working with (AssemblyComponentDefinition.iAssemblyFactory or AssemblyComponentDefinition.iAssemblyMember).  Once you have the iAssemblyFactory object, you can use its DefaultRow property to specify which row of that iAssembly table should be the 'default' one, which will also 'activate' the model that row represents, to show it on your screen (as long as iAssemblyFactory document was already the one showing on your screen).

AssemblyDocument 

AssemblyComponentDefinition 

iAssemblyFactory 

iAssemblyFactory.DefaultRow 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 7

parth_moradiya
Contributor
Contributor

Thanks

0 Likes
Message 4 of 7

parth_moradiya
Contributor
Contributor

Thank you for your reply. I am a beginner in ilogic. and information you gave me; I am not able to understand it. I just want to activate iassembly member at specific condition using ilogic. For example, if voltage is 24 then activate member 1. if voltage 110 then activate member 2 and all. So at different voltages. I just want to change the rows of iassembly table using ilogic. Thanks.

0 Likes
Message 5 of 7

WCrihfield
Mentor
Mentor
Accepted solution

Hi @parth_moradiya.  In order to be able to activate a specific iAssembly member by code, we would need to be able to first find the iAssembly configuration table, then find a specific column within that table, by its heading, for the variable you are looking for (such as voltage), then we would have to find one specific row within that whole table that has the one specific value you are looking for in that one column.  Without being super familiar with your model files or your iAssembly table, that is very difficult for someone else to write the code for.  Besides that, where is this initial value going to be obtained from, that will be used to dictate which member should be activated.  Is that a user parameter within the main iAssembly file that is not included within the iAssembly table anywhere?  What is the name of this parameter that we need to check the value of?  And also, what is the name of the column within the iAssembly table that will contain the values for this parameter, if there is a column in there for it.  If there is no column in there for it, then how would the code know which row / member to activate for different values?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 7

parth_moradiya
Contributor
Contributor

Thank you. It's sorted now.

Message 7 of 7

WCrihfield
Mentor
Mentor

Without knowing anything at all about your iAssembly, what value to check, what column to find, or how to find the row in the table that matches the search criteria, I just created an iLogic rule example with two things in mind.  This code expects that the document currently showing on your screen when this rule starts is the main iAssembly factory document.  Then it expects there to be a column within the iAssembly configuration table with the heading "VOLTAGE".  Then it expects to find a row within that table, where the value for that row, in that column is "24".  If any of these are not true, the code will fail.

'make sure we are working with an assembly (not a part or drawing)
Dim oADoc As AssemblyDocument = TryCast(ThisDoc.Document, Inventor.AssemblyDocument)
If oADoc Is Nothing Then
	MsgBox("The iLogic rule named '" & iLogicVb.RuleName & _
	"' exited, because it did not obtain a reference to an assemby.", vbCritical, "iLogic")
	Return 'this will exit this iLogic rule
End If
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
'figure out if this assembly is just a regular assembly, or an iAssemblyFactory, or an iAssemblyMember.
Dim oFactory As iAssemblyFactory = Nothing
If oADef.IsiAssemblyFactory Then
	oFactory = oADef.iAssemblyFactory
ElseIf oADef.IsiAssemblyMember Then
	Dim oMember As iAssemblyMember = oADef.iAssemblyMember
	oFactory = oMember.ParentFactory
End If
If oFactory Is Nothing Then
	MsgBox("This assembly is not an iAssembly factory, and a reference to an iAssembly factory could not be obtained.", _
	vbCritical, "iLogic")
	Return 'this will exit this iLogic rule
End If

'try to find the table column containing the variable we are looking for (voltage)
Dim oCols As iAssemblyTableColumns = oFactory.TableColumns
Dim oVoltageColumn As iAssemblyTableColumn = Nothing
For Each oCol As iAssemblyTableColumn In oCols
	If oCol.DisplayHeading = "VOLTAGE" Then
		oVoltageColumn = oCol
		Exit For
	End If
Next oCol
If oVoltageColumn Is Nothing Then
	MsgBox("Could not find a column in the iAssembly table named 'VOLTAGE'.", vbCritical, "iLogic")
	Return 'this will exit this iLogic rule
End If

'try to find the table row which has a specific value in that one column we found earlier
Dim oRows As iAssemblyTableRows = oFactory.TableRows
Dim oMatchingRow As iAssemblyTableRow = Nothing
For Each oRow As iAssemblyTableRow In oRows
	If oRow.Item(oVoltageColumn).Value = "24" Then
		oMatchingRow = oRow
		Exit For
	End If
Next oRow
If oMatchingRow Is Nothing Then
	MsgBox("Could not find a row in the iAssembly table where the value in its 'VOLTAGE' column was 24.", vbCritical, "iLogic")
	Return 'this will exit this iLogic rule
End If
oFactory.DefaultRow = oMatchingRow
oADoc.Update2(True)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes