Color List in iLogic

Color List in iLogic

Anonymous
Not applicable
2,229 Views
5 Replies
Message 1 of 6

Color List in iLogic

Anonymous
Not applicable

How can I generate a list of colors to chose from?

Just as I can generate a list of materials to chose from:

 

MultiValue.List("primary_mat") = iProperties.Materials

 

I don't seem to be able to do the same for Colors:

 

MultiValue.List("primary_color") = iProperties.PartColor

 

The "iProperties.PartColor" was generated from the available code "snippets" in the iLogic editior, so I assume it is a valid choice.

 

I get the following error message:

"Unable to cast object of type 'System.String' to type 'System.Collections.IList'. "

 

Inv2011

 

Thanks,

Mike

 

0 Likes
Accepted solutions (2)
2,230 Views
5 Replies
Replies (5)
Message 2 of 6

MjDeck
Autodesk
Autodesk
Accepted solution

Here's a rule to get a list of the available colors:

Dim colorList As New ArrayList
For Each style As RenderStyle In ThisDoc.Document.RenderStyles
  colorList.Add(Style.Name)
Next
MultiValue.List("primary_color") = colorList

 iProperties.PartColor will give you the current color of the part.  You can also use it to set the color of the part.  For instance:

 iProperties.PartColor = primary_color

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 6

Anonymous
Not applicable
Accepted solution

Thanks! It worked!

How can one discover what functions to use if there are no appropriate "snippets" to use? How did you know about the RenderStyles object?

 

Thanks!

Mike

0 Likes
Message 4 of 6

MjDeck
Autodesk
Autodesk

The RenderStyles object is not specific to iLogic.  It's provided by the Inventor API.  You can see documentation for the API under Help -> Additional Resources -> Programming Help.  That has a lot of examples (mostly in VBA, but they can be converted to VB.NET for iLogic).

 We should probably add more snippets like this one to iLogic.

 

The main access points to the API from iLogic are the two predefined objects:

ThisDoc.Document  ' API type:  Inventor.Document

ThisApplication       ' API type :  Inventor.Application


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 6

Anonymous
Not applicable

Thanks again Mike,

I have a related question. I have done my best to sift through the topics in the   Help -> Additional Resources -> Programming Help section. For an interface that supposedly requires little if any programming background, it sure seems like you have to be an adavanced programmer to even know where to begin to look for inofrmation.

I am working through the iLogic tutorials, and the one for iLogic Assembly

http://wikihelp.autodesk.com/Inventor/enu/2012/Help/2144-Tutorial2144/2145-Inventor2145/2345-iLogic_...

 contains this code:

GoExcel.CellValue("part_number.xls", "Sheet1", "Block_Type") = component_type
GoExcel.CurrentCellValue("Block_Style") = block

 

How would I go about finding out what the difference is between

GoExcel.CellValue

and

GoExcel.CurrentCellValue

?

Thank you

 

 

 

 

0 Likes
Message 6 of 6

MjDeck
Autodesk
Autodesk

The GoExcel functions are specific to iLogic.  They are not documented in the Additional Resources -> Programming Help.  The iLogic functions are described in the installed help on Inventor 2011, in the main help under:

Autodesk Inventor -> iLogic -> Functions -> Quick Reference

Excel Data Links functions are on that page.

For the online Wikihelp, it's in a similar location but under References instead of Quick Reference.  Here's a link for Inventor 2012:

http://wikihelp.autodesk.com/Inventor/enu/2012/Help/0073-Autodesk73/0673-iLogic673/0676-Function676#...

________________________

CurrentCellValue is very similar to CellValue.  In fact, you don't have to use CurrentCellValue.  You can use CellValue instead.

For CellValue, you can specify either:

-  the filename (or 3rd Party embedding or link name), sheet name and cell address

or

-  just the cell address

 

For CurrentCellValue, you can only specify the cell address.  That's the idea behind the name: it uses the current file and sheet name.  These are set up by a previous call to CellValue (or to GoExcel.Open).

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes