# Ruby API Documentation - Errors & Suggestions

**URL:** <https://forums.sketchup.com/t/ruby-api-documentation-errors-suggestions/10958>\
**Category:** Ruby API\
**Created:** [May 8, 2015, 4:29pm UTC](https://forums.sketchup.com/t/ruby-api-documentation-errors-suggestions/10958 "2015-05-08T16:29:09Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [May 12, 2015, 9:05pm UTC](https://forums.sketchup.com/t/ruby-api-documentation-errors-suggestions/10958/9 "2015-05-12T21:05:29Z")

</div>

> [@slbaumgartner](#):
>
> This kind of Text should be a separate class of Entity or at least provide a method to determine it is a note (`Text#is_note?`) instead of requiring users to know the workaround of testing for `#point.nil? && !#has_leader?`.

Agreed.

I’d like to see view locked notes as a **subclass of `Sketchup::Text`** with the added methods it needs, and the useless ones from the superclass undefined for the subclass.

Names for the class could be **`ViewNote`** or **`TextNote`**.

(_I prefer the former as it indicates the anchoring to the viewport_.)

Additional methods needed might contain:

**`#anchor`** : Return an array of the position scales `[x_scale, y_scale]` from the upper left corner of the viewport. (The scales being a Float between 0.0 and 1.0.)

**`#anchor=`** : Accepts an array of the position scales `[x_scale, y_scale]` from the upper left corner of the viewport. (The scales being a Float between 0.0 and 1.0.) **Cause an undo entry**.

**`#set_anchor`** : Accepts an array or a list of two values, of the position scales `[x_scale, y_scale]` from the upper left corner of the viewport. (The scales being a Float between 0.0 and 1.0.) **Should not cause an undo entry**.

(Currently in order to move a note, we have to save it’s text, erase it, and recreate it. This causes an undo entry.)

**`#outline`**  
**`#outline=`** : thickness of outline (0 if none), unit (:em,:px, etc.)

**`#padding`**  
**`#padding=`** : thickness of padding (use nil for default in setter.), unit (:em,:px, etc.)

**`#background`**  
**`#background=`** : Sketchup::Material object (nil if none.) Would allow transparency.

**`#color`**  
**`#color=`** : Sketchup::Color object (nil if default.)

**`#font`** : reference to font object to get & set **`face`** , **`style`** & **`size`** (and choose between pts & %, or assume % if value is Float between 0.0 and 1.0 ?)

* * *

**EDIT (2019-02-19)** : Added an issue to the official API issue tracker at GitHub …

> <https://github.com/SketchUp/api-issue-tracker/issues/207>
>
> \### SketchUp Ruby API Issue
> 
> \## View notes could be a subclass of \[\*\*\`Sketchup…::Text\`\*\*\](http://ruby.sketchup.com/Sketchup/Text.html)
> 
> \> \[Steve Baumgartner said\](https://forums.sketchup.com/t/ruby-api-documentation-errors-suggestions/10958/7) ...
> \>
> \>\[\*\*\_\`Model\`\_\`#add\_note\`\*\*\](http://ruby.sketchup.com/Sketchup/Model.html#add\_note-instance\_method) creates a restricted kind of \[\*\*\`Text\`\*\*\](http://ruby.sketchup.com/Sketchup/Text.html) Entity. It does not have a \[\*\*\`Point3d\`\*\*\](http://ruby.sketchup.com/Geom/Point3d.html) position or a leader and can not have these properties set despite responding to the methods for them.
> \>
> \>It also has useless values of the other attributes of a \[\*\*\`Text\`\*\*\](http://ruby.sketchup.com/Sketchup/Text.html) related to leaders. These methods return default values that have no impact on the display.
> \>
> \>This kind of \_object\_ should be a separate class of Entity or at least provide a method to determine it is a note (\*\*\`Text#is\_note?\`\*\*) instead of requiring users to know the workaround ...
> \> \`\`\`ruby
> \> point.nil? && !has\_leader?
> \> \`\`\`
> 
> I agree to a \*\*\`#is\_note?\`\*\* query method, but really (along with others who've expressed the same wishes,) would like to see view locked notes as a \*\*subclass of \[\`Sketchup::Text\`\](http://ruby.sketchup.com/Sketchup/Text.html)\*\* with the added methods it needs, and the useless ones from the superclass \*\*undefined for the subclass\*\*.
> 
> Names for the class could be \*\*\`ViewNote\`\*\* or \*\*\`TextNote\`\*\*. 
> 
> (\*I prefer the former as it indicates the anchoring to the viewport\*.)
> 
> Additional methods needed might contain:
> 
> \*\*\`#anchor\`\*\* : Return an array of the position scales \`\[x\_scale, y\_scale \]\` from the upper left corner of the viewport. (The scales being a Float between 0.0 and 1.0.)
> 
> \*\*\`#anchor=\`\*\* : Accepts an array of the position scales \`\[x\_scale, y\_scale \]\` from the upper left corner of the viewport. (The scales being a Float between 0.0 and 1.0.) \*\*Cause an undo entry\*\*.
> 
> \*\*\`#set\_anchor\`\*\* : Accepts an array or a list of two values, of the position scales \`\[x\_scale, y\_scale \]\` from the upper left corner of the viewport. (The scales being a Float between 0.0 and 1.0.) \*\*Should not cause an undo entry\*\*.
> 
> (Currently in order to move a note, we have to save it's text, erase it, and recreate it. This causes an undo entry.)
> 
> \*\*\`#outline\`\*\*
> \*\*\`#outline=\`\*\* : thickness of outline (0 if none), unit (:em,:px, etc.)
> 
> \*\*\`#padding\`\*\*
> \*\*\`#padding=\`\*\* : thickness of padding (use nil for default in setter.), unit (:em,:px, etc.)
> 
> \*\*\`#background\`\*\*
> \*\*\`#background=\`\*\* : Sketchup::Material object (nil if none.) Would allow transparency.
> 
> \*\*\`#color\`\*\*
> \*\*\`#color=\`\*\* : Sketchup::Color object (nil if default.)
> 
> \*\*\`#font\`\*\* : reference to font object to get & set \*\*\`face\`\*\*, \*\*\`style\`\*\* & \*\*\`size\`\*\* (and choose between pts & %, or assume % if value is Float between 0.0 and 1.0 ?)
> 
> \*\*\`#bounds2d\`\*\* Using 3D bounds will always fail for a 2D screen space object. Because the font size can be changed, we would need to get a \[\`Geom::Bounds2d\`\](https://ruby.sketchup.com/Geom/Bounds2d.html) object for screen notes.
> 
> \----
> \_Originally posted to the public forums in May of 2015, as \[post 7\](https://forums.sketchup.com/t/ruby-api-documentation-errors-suggestions/10958/7) and \[post 9\](https://forums.sketchup.com/t/ruby-api-documentation-errors-suggestions/10958/9) ...\_

---

_[View the full topic](https://forums.sketchup.com/t/ruby-api-documentation-errors-suggestions/10958)._
