Wednesday, November 29, 2023
Home3D ModelingMulti-Line 3D textual content - Ruby API

Multi-Line 3D textual content – Ruby API


I can’t appear to seek out any threads on this subject however it could have been answered earlier than.

I’m making an attempt to determine if there may be approach to generate multi-line 3D textual content with the API.

Can I insert a newline character or another particular character that may trigger the API to create a number of traces of textual content?


n

image

def test_text(textual content)
  entities = Sketchup.active_model.entities
  entities.add_3d_text(textual content, TextAlignLeft, "Arial")
finish
test_text( "myntest")



3 Likes

BTW
It is very important use " double quotes to outline the string, in any other case :

image



3 Likes

Thank-you, that is very thrilling, I didn’t notice I may do multi-lines with the 3D textual content.



3 Likes

This may be mounted inside the strategy …

def test_text(textual content)
  entities = Sketchup.active_model.active_entities
  textual content.gsub!('n',"n")
  entities.add_3d_text(textual content, TextAlignLeft, "Arial")
finish



3 Likes

On a associated be aware does anybody know what the precise integer values are for the constants:

TextAlignLeft

TextAlignRight

TextAlignCenter

I can’t appear to seek out this wherever within the documentation.

Sketchup defines these constants on the prime degree NameSpace

You may merely sort the identify into the Ruby Console to retrieve the worth.
TextAlignLeft = 0
TextAlignCenter = 1
TextAlignRight = 2

Or , in any Module you possibly can search for the worth of a single fixed with the const_get() technique utilizing identify of the fixed as a Image.

Object.const_get(:TextAlignCenter)

or dump the gamut

Object.constants.type.every { | const |
  places "#{const} = #{ Object.const_get(const) }"
}
nil

Object being the default root of all Ruby objects.

Tomtom has produced a plugin that enables the insertion of editable multiline 3D textual content.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments