I have a script that I'm running against a graphic to change a number of things.. line width, style, etc. One thing I need to change is the object's color. I have a custom color set with custom names. I would like the script to be able to set the color to the custom color name rather than just looking at the color value.. ie. "1505656". I don't know how to access those color sets in VBA.
Thanks.
Under your object there will be animations that will have a generic name unless someone has renamed them (I did in the screen shot below) which contain the shared table name where you can see the object name in the left column of properties for the color table being used.
So an example vba line to update this would be:
afgRect113.SharedTableName = "User.Pump_DValve_Fill_Color_Tan"
I seem to recall there being an issue with doing this however and getting the object to refresh until the animation value has changed.
In reply to Cedric Dawnhawk:
In reply to TreyB:
You would set the Source to "Line_Process" and the SharedTableName maybe wouldn't change if I'm understanding what you are trying to do then. Here are the iFix view of the properties sent earlier
Might be better to explain the overall end goal to fully understand what you are trying to do. Just keep in mind you will have to migrate this to DeltaV Live potentially in the near future.
In reply to Matt Stoner:
I should have read your initial post more carefully where you do refer to colour sets rather than colour tables, which is the usual way of setting custom colours.
I didn't know a lot about how colour sets worked but after a bit of investigation it appears that If a colour property of an object is set using anything other than the default colour set, the property becomes ‘indirected’ and the name of the custom colour set and the name of the colour are stored in a list and the colour property is set to the numeric value defined in the custom color set.
To set a colour from a custom colour set programmatically you need to use some of the (hidden) methods for manipulating the indirected information.
So instead of:
Shape.EdgeColor = 6974058
you need two lines:
Shape.SetupPropertyIndirection "EdgeColor", strTable, strEntryShape.UpdateIndirectedProperties
where strTable is the name of the table without the .ftb extension ("POET_GS"?) and strEntry is the name assigned to the colour you want ("Line_Process"?). These are case-sensitive. The first line sets up the information about the custom colour then the second updates the EdgeColor property with the numerical value of the colour from the custom colour set.
I have some notes on the other indirected methods which may be of interest. These are hidden methods and some IFix documentation I have says they are "Reserved for internal purposes". However I have tried them out on my development system and they seem to work OK.
You need to use a couple of the other "hidden" methods.
bIndirect = txtObject.IsPropertyIndirected(strProp)
where bIndirect is a Boolean variable indicating if the property is "Indirected", txtObject is the shape you are testing and strProp is the name of the property, "EdgeColor" in your case.
Then
If bIndirect Then txtObject.GetIndirectedProperty strProp, strTable, strEntryEnd If
where strTable and strEntry are variables that will be updated with the custom colour table name and the name of the custom colour. GetIndirectedProperty throws an error if the property is not indirect, so you must do the bIndirect test first.
Then just test strTable and strEntry to see if they are the values you are looking for.
I will email you directly the full notes I have about these methods so if anything else crops up you may be able to sort it.