I have created a shape in a moho script and given it a style (just a stroke and fill) and named that style, but it doesn't appear in the styles pallete. What am I missing?
(for bevity I have left the shape code out, but the shape creates fine with the correct style attributes)
Code: Select all
local shapeid = moho:CreateShape(true,false,0)
local shape = mesh:Shape(shapeid)
shape:SetName("my shape")
shape.fMyStyle.fLineWidth = 0.01
local rgbCol = LM.rgb_color:new_local()
rgbCol.r = 255
rgbCol.g = 0
rgbCol.b = 0
rgbCol.a = 255
shape.fMyStyle.fLineCol:SetValue(0, rgbCol)
rgbCol.r = 0
rgbCol.g = 255
rgbCol.b = 0
rgbCol.a = 255
shape.fMyStyle.fFillCol:SetValue(0, rgbCol)
local stylename = LM.String:new_local()
stylename:Set("my style")
shape.fMyStyle.fName = stylename
Code: Select all
for styleIndex = 0, moho.document:CountStyles()-1 do
print(styleIndex.." > "..moho.document:StyleByID(styleIndex).fName:Buffer())
end
Then I came across AddStyle function. It has no documentation and there are no scripts listed as using it. I tried to call it in the following manner:
Code: Select all
moho.document:AddStyle(shape.fMyStyle)
What am I missing?
BTW I can select the shape using its name from the style pallete and that way change its style but thats not what I am after as I will be creating lots of shapes across many layers so need to be able to change all of them in one go.
Thank you for any help.