# Workarounds for backward compatibilty

**URL:** <https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678>\
**Category:** Ruby API\
**Created:** [February 4, 2015, 5:24pm UTC](https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678 "2015-02-04T17:24:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [February 4, 2015, 5:24pm UTC](https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678/1 "2015-02-04T17:24:47Z")

</div>

I see these code segments in some examples: are they still necessary for backward compatibility?

```auto

`#Shim for the Set class which was moved in SketchUp 2014.
if defined?(Sketchup::Set)
    Set = Sketchup::Set
end

```

and this:

```auto
if tb.get_last_state == TB_NEVER_SHOWN
  # Hide toolbar at first startup
  tb.hide
else
  tb.restore
  # Per bug 2902434, adding a timer call to restore the toolbar. This
  # fixes a toolbar resizing regression on PC as the restore() call
  # does not seem to work as the script is first loading.
  UI.start_timer(0.1, false) {
    tb.restore
  }
end

```

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [February 4, 2015, 5:41pm UTC](https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678/2 "2015-02-04T17:41:37Z")

</div>

> [@barry\_milliken\_droid](#):
>
> I see these code segments in some examples: are they still necessary for backward compatibility?
> 
> `#Shim for the Set class which was moved in SketchUp 2014.if defined?(Sketchup::Set) Set = Sketchup::Setend

If you use the Set class that ships with SketchUp prior to SU2014, yes. They always will be. Though we don’t recommend the use of that old class. The Set class from the Ruby Standard Library is much better and faster - but only exist in SU2014 and up.

> [@barry\_milliken\_droid](#):
>
> if tb.get\_last\_state == TB\_NEVER\_SHOWN # Hide toolbar at first startup tb.hideelse tb.restore # Per bug 2902434, adding a timer call to restore the toolbar. This # fixes a toolbar resizing regression on PC as the restore() call # does not seem to work as the script is first loading. UI.start\_timer(0.1, false) { tb.restore }end

For extensions that run on newer SketchUp versions, no this isn’t needed. But if you want to support older SketchUp versions - then yes, you need to use that.

Personally I don’t really bother to code for SketchUp versions older than SU2014 any more. The inclusion of Ruby 2.0 and the standard library and other bug fixes doesn’t make support for older versions worth it.

(P.S. Cn yoy wrap code as Preformated Text when you post? Makes it much easier to read code.)

---

<div class="post-metadata">

**Author:** ![Aerilius](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Aerilius](https://forums.sketchup.com/u/Aerilius)\
**Post date:** [February 4, 2015, 5:56pm UTC](https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678/3 "2015-02-04T17:56:32Z")

</div>

> [@barry\_milliken\_droid](#):
>
> `# Per bug 2902434` […]

When using workarounds (this one is copy-pasted from a SketchUp example), it is always good to specify how long the work-around is valid, if a time is known, or at least the exact circumstances/reasons under which the work-around was needed. So you don’t collect lots of legacy code and you know what can be cleaned up.

I believe bug #2902434 was fixed, but in what version was it? There is no easy way to look up…

---

<div class="post-metadata">

**Author:** ![barry\_milliken\_droid](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/barry_milliken_droid/32/4612_2.png) [@barry\_milliken\_droid](https://forums.sketchup.com/u/barry_milliken_droid)\
**Post date:** [February 4, 2015, 6:09pm UTC](https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678/4 "2015-02-04T18:09:57Z")

</div>

I’m not an HTML guy. How do I wrap preformatted text?

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [February 4, 2015, 7:01pm UTC](https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678/5 "2015-02-04T19:01:57Z")

</div>

> [@Aerilius](#):
>
> I believe bug #2902434 was fixed, but in what version was it? There is no easy way to look up…

That’s before my time - that issue reference is for some old issue tracker that we don’t use any more I’m afraid.

> [@barry\_milliken\_droid](#):
>
> How do I wrap preformatted text?

You can use the formatting toolbar:

---

<div class="post-metadata">

**Author:** ![Aerilius](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Aerilius](https://forums.sketchup.com/u/Aerilius)\
**Post date:** [February 4, 2015, 7:55pm UTC](https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678/7 "2015-02-04T19:55:14Z")

</div>

Certainly. So that we can help you, it would be good to know what the problem is. Best you create your own question by clicking [**+New Topic**](http://forums.sketchup.com/) and describe the problem in detail.

---

<div class="post-metadata">

**Author:** ![kattyerazo\_suka](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@kattyerazo\_suka](https://forums.sketchup.com/u/kattyerazo_suka)\
**Post date:** [February 4, 2015, 7:58pm UTC](https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678/8 "2015-02-04T19:58:46Z")

</div>

I have done that several times, i didnt get any answer, i also tried by private messages, i cant open my file, it says unexpected file format and then it closes.  
sorry about the writing my native language is spanish

---

<div class="post-metadata">

**Author:** ![Aerilius](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Aerilius](https://forums.sketchup.com/u/Aerilius)\
**Post date:** [February 4, 2015, 10:53pm UTC](https://forums.sketchup.com/t/workarounds-for-backward-compatibilty/6678/9 "2015-02-04T22:53:07Z")

</div>

I see Jim started giving you an answer. I will also take a look. It is really enough if you upload your file only once, and keep the question focussed in one thread. Usually we reply in every thread, though maybe not as fast as an ambulance.
