In order to render text, one can build text objects using cmd as
cmd = []
cmd.Add(’-_TextObject’)
cmd.Add(’_GroupOutput=Yes’)
cmd.Add(’_FontName=Arial’)
cmd.Add(’_Italic=No’)
cmd.Add(’_Bold=Yes’)
cmd.Add(’_Height=50’)
cmd.Add(’_Output=Solids’)
cmd.Add(’_Thickness=1’)
cmd.Add(’_AddSpacing=No’)
cmd.Add(’“Text”’)
cmd.Add(‘0,0,0’)
cmd.Add(‘Enter’)
sendCmd = ’ '.join(cmd)
rs.Command(sendCmd,False)
ido=rs.LastCreatedObjects()
rs.RotateObject(ido,(0,0,0),90,(1,0,0))
rs.MoveObject(ido,(0,-3,50))
for i in ido:
rs.MatchMaterial(MyMaterialIndex,i)
This however does not work properly, for instance when there are several text objects with different fonts.
Is there a more effective way to script the construction of a text object ?
This is the only way currently to script TextObject. You should be able to change the font at will however, simply by changing the _FontName=XX value and re-creating your command string before calling it with rs.Command. For that reason, I would maybe encapsulate your command string as a separate definition and call it for every object with whatever parameters you want to use for that object.
Thanks for your answer !
Repeating the command mix the fonts in the various text objects.
This way is therefore not useful as it is.
I wonder whether there is a more robust solution !