ilogic Could a Multivalue list b shared in several options for component replace

ilogic Could a Multivalue list b shared in several options for component replace

Anonymous
Not applicable
672 Views
3 Replies
Message 1 of 4

ilogic Could a Multivalue list b shared in several options for component replace

Anonymous
Not applicable

Hi,

I have this assembly where I have several components that I want to replace. I am using a multivalue.setlist for coding. It does work, but I was wondering if there is a better shorter way coding to accomplish the same task? is there a way to share the list since the list is the same for all components? Also I will be adding more components to the list in the future the components location will always be the same just the file name will change. So it would be nice is if I add a new component name to the list it will update and be able to replace the new component with the value I just added without me having to pinpoint where the file is. I just want to find a better way to code this since I will be updating the coding everyso often and the coding already is very long. I am attaching my form and my coding I just added code for two device 1, and device 2 . I still need to add coding for device 3-5. Let me know if you have any ideas. Thank you

form2.png

 

 PARAMETERS.png

 

 

 MultiValue.SetList("Device1PN","EXP-PB-004-B", "EXP-PB-004-G", "EXP-PB-004-MH", "EXP-PB-004-R","EXP-PB-004-R-1",

"EXP-PB-005-B","EXP-PB-005-G", "EXP-PB-005-G-1", "EXP-PB-005-MH-R", "EXP-PB-005-MH-R-01", "EXP-PB-005-MH-R-1",  "EXP-PB-005-R", "EXP-PB-005-R-1",

"EXP-PL-002-R", "EXP-PL-003-A", "EXP-PL-003-A024", "EXP-PL-003-A240","EXP-PL-003-G","EXP-PL-003-G024","EXP-PL-003-G240","EXP-PL-003-R",

"EXP-PL-003-R024","EXP-PL-003-R24","EXP-PL-003-R240","EXP-PL-003-W","EXP-PL-003-W024","EXP-PL-003-W240",

"EXP-REP-10K0201","EXP-SEL-2POS-02","EXP-SEL-2POS-03","EXP-SEL-2POS-04","EXP-SEL-3POS-01","EXP-SEL-3POS-02","EXP-SW-001","EXP-SW-002" )

 

If Device1used=True Then

Select Case Device1PN

Case "EXP-PB-004-B"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-004-B.ipt", False)

Case "EXP-PB-004-G"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-004-G.ipt", False)

Case "EXP-PB-004-MH"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-DEVICE-003.ipt", False)

Case "EXP-PB-004-R"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-004-R.ipt", False)

Case "EXP-PB-004-R-1"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-004-R-1.ipt", False)

Case "EXP-PB-005-B"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-B.ipt", False)

Case "EXP-PB-005-G"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-G.ipt", False)

Case "EXP-PB-005-G-1"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-G-1.ipt", False)

Case "EXP-PB-005-MH-R"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-MH-R.ipt", False)

Case "EXP-PB-005-MH-R-1"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-MH-R-1.ipt", False)

Case "EXP-PB-005-R"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-R.ipt", False)

Case "EXP-PB-005-R-1"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-R-1.ipt", False)

Case "EXP-PL-002-R"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-002-R.ipt", False)

Case "EXP-PL-003-A"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-A.ipt", False)

Case "EXP-PL-003-R240"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-R240.ipt", False)

Case "EXP-PL-003-W"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-W.ipt", False)

Case "EXP-PL-003-W024"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-W024.ipt", False)

Case "EXP-PL-003-W240"

Component.Replace("DEVICE1", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-W240.ipt", False)

End Select

End If

 

 MultiValue.SetList("Device2PN","EXP-PB-004-B", "EXP-PB-004-G", "EXP-PB-004-MH", "EXP-PB-004-R","EXP-PB-004-R-1",

"EXP-PB-005-B","EXP-PB-005-G", "EXP-PB-005-G-1", "EXP-PB-005-MH-R", "EXP-PB-005-MH-R-01", "EXP-PB-005-MH-R-1",  "EXP-PB-005-R", "EXP-PB-005-R-1",

"EXP-PL-002-R", "EXP-PL-003-A", "EXP-PL-003-A024", "EXP-PL-003-A240","EXP-PL-003-G","EXP-PL-003-G024","EXP-PL-003-G240","EXP-PL-003-R",

"EXP-PL-003-R024","EXP-PL-003-R24","EXP-PL-003-R240","EXP-PL-003-W","EXP-PL-003-W024","EXP-PL-003-W240",

"EXP-REP-10K0201","EXP-SEL-2POS-02","EXP-SEL-2POS-03","EXP-SEL-2POS-04","EXP-SEL-3POS-01","EXP-SEL-3POS-02","EXP-SW-001","EXP-SW-002" )

 

If Device2used=True Then

Select Case Device2PN

Case "EXP-PB-004-B"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-004-B.ipt", False)

Case "EXP-PB-004-G"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-004-G.ipt", False)

Case "EXP-PB-004-MH"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-DEVICE-003.ipt", False)

Case "EXP-PB-004-R"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-004-R.ipt", False)

Case "EXP-PB-004-R-1"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-004-R-1.ipt", False)

Case "EXP-PB-005-B"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-B.ipt", False)

Case "EXP-PB-005-G"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-G.ipt", False)

Case "EXP-PB-005-G-1"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-G-1.ipt", False)

Case "EXP-PB-005-MH-R"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-MH-R.ipt", False)

Case "EXP-PB-005-MH-R-1"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-MH-R-1.ipt", False)

Case "EXP-PB-005-R"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-R.ipt", False)

Case "EXP-PB-005-R-1"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PB-005-R-1.ipt", False)

Case "EXP-PL-002-R"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-002-R.ipt", False)

Case "EXP-PL-003-A"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-A.ipt", False)

Case "EXP-PL-003-R240"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-R240.ipt", False)

Case "EXP-PL-003-W"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-W.ipt", False)

Case "EXP-PL-003-W024"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-W024.ipt", False)

Case "EXP-PL-003-W240"

Component.Replace("DEVICE2", "C:\NEEL\Libraries\Purchased Parts\E\EXP-PL-003-W240.ipt", False)

End Select

End If

0 Likes
Accepted solutions (1)
673 Views
3 Replies
Replies (3)
Message 2 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@Anonymous,

 

For my understanding, usage of excel or spread sheet would be a best approach. For demonstration, try the below iLogic code and attached excel with this post.

 

MultiValue.List("Device1PN") = GoExcel.CellValues("Path\Example.xlsx", "Sheet1", "A1", "A35")

After downloading excel, make sure that downloaded path should be updated in above iLogic code. The cells value would look like below.

 

Excel_list.JPG

 

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 4

Anonymous
Not applicable

Yes the solution resolves the first part of my question Thank you, but what about the second part?

 

So it would be nice is if a designer adds a new component to the list thru the menu it will add to the list (excel sheet) and be able to replace the new component with the new value (new part) without me having to add additional code to execute the replace. I am attaching my coding below as you see it is still kind of long but a lot better.

 

 

MENU.png

0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Try the following iLogic code to add a component name to existing list.

 

oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
	'Setting an userParameter as text parameter
Try
	otester = oMyParameter.Item("MultiValue_lists")
Catch
	oInsulationType=oMyParameter.AddByValue("MultiValue_lists", "", UnitsTypeEnum.kTextUnits) 
	'make parameter a multivalue list parameter
	MultiValue.SetList("MultiValue_lists", "Device1PN", "Device2PN", "Device3PN","Device4PN", "Device5PN", "Device6PN")
End Try

'set list parameter to use array list    
'MultiValue.List("MultiValue_lists") = NameList

'get user input
oSelection = InputListBox("Select one:", MultiValue.List("MultiValue_lists"), _
Parameter("MultiValue_lists"), "iLogic", "List of Component Occurrences:")

'catch null selection
If oSelection = "" Then
	Return 'exit rule
Else
	'set parameter value 
	Parameter("MultiValue_lists") = oSelection
End If

value = InputBox("Enter Component name to add in " + oSelection + " list" , "Adding Component", "VMAA4-XXXXXX")

values = MultiValue.List(oSelection)

Dim cnt As String 
cnt = (values.Count + 1).ToString

GoExcel.CellValue("Path of Excel\Example.xlsx", "Sheet1", "A"&cnt) = value

GoExcel.Save

GoExcel.Close


Before running this code, make sure that file path of excel is updated in code.

 

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes