styles are not setable with python

3025
8
01-08-2021 09:34 AM
romainjanil
New Contributor III

i think they should have a get/set method

8 Comments
DevinLavigne

agree with this 100%. Would be very nice to code into predefined styles.

ThomasFuchs

Hello @romainjanil and @DevinLavigne 

Thanks for your input. With python it is indeed only possible to set attributes, but no styles.

The CE team is looking into this.

Thanks 

Thomas Fuchs

romainjanil

great, I didn't realized this wasn't possible till I tried to use a similar feature (pre set some geo styles with local attributes values inside a generic geo-typical rule file and call them depending on the shape geo-location)

DevinLavigne

Thanks @ThomasFuchs  - cga too right?

ThomasFuchs

@DevinLavigne yes, from within CGA, it is not possible to set a style.

Styles can only be selected in the CE Inspector.

ElliotHartley

This would be of great help in a number of projects. I've cobbled together a style creator (for external assets) in python but having a formal way of doing all of this would be nice.

Clover4

I agree that a new way to get/set styles is the ideal here and came to find out if it was possible, which it is not.  

But one workaround after you create the style is turn it back into a function.   So a style gets transformed from:

style SuperStyle
attr Color = "Red"

Use a find and replace on your style selection:

Find:  "attr"   Replace "set("

Find: "="      Replace ","

I can't get the carriage return to work for setting the " ) " so that's has to been done manually.

And then loop it back to ruleset however in the stack you placed it, probably all the way at the top.

Now your style is a function and can be used in conditional logic. 

SuperStyle-->
   set(Color,"Red")
   NextRule  //Your setting your attributes at the top of your ruleset and this a detour.

 

But yeah, a get/set is what we need.   

 

ChristianIten
Status changed to: Under Consideration