Basics of groups and components with the Ruby API

Continuing the discussion from How to create a component with existing entities in a component by ruby?:

The following was slightly off-topic from the other thread discussing creating a group instance copy of the same scale as the original, … so I’ve started a new topic.

1 Like

There are. They are instance methods of a group or component definition’s Entities collection (where they should be.)

Visual Basic for Applications is not Ruby.

You need to understand that every big fan of every of language other than Ruby, has come into every SketchUp forum there ever was, and disparaged Ruby and the SketchUp Ruby API,… because it does not do things the way their favorite language does.

Ruby does things the Ruby way. And the SketchUp Ruby API is no more than an extension to the Ruby objectspace. (To be effective more quickly, requires a coder learn basic Ruby first.)

ADD: Usually, when someone comes into a Ruby API forum, waving the flag of another language, saying that Ruby and the API does not do things correctly,… well that will upset some of us a little bit. But we are somewhat used to it, as it has happened so many times in the past.

This can also be done. Such operations are programmed using the API’s Ruby Tool class.

Also new for SketchUp 2016, are two selection wizard methods of the PickHelper class:

In Ruby, a “handle” is called an object reference.

A “name” is a designation of an built-in attribute (property) of both instances and definitions, which is gotten or set via methods identified as name() and name=(). (Ie, instances can have a different value for their name property, than their definition has.)

Which also exist. It is standard in geometry to create and apply transformations.
See the APi’s Geom::Transformation class.

The Group and ComponentInstance classes have these instance methods you speak of.

But are not limited to “simple”. They have the full power of whatever transformation the coder creates. (If they were “limited”, we would be bitchin’ for more power. :wink:)

Mirror ? There are plugins to mirror objects that might help. But this operation usually needs user interaction, so it is programmed as a Ruby Tool class.

This is an instance method of the Sketchup::Face class.
see Face # followme


Dan you are a guiding light, and your sharing very appreciated. However, when I see ambiguous “end” statements in ruby, that too should and will pass. Your and others in-depth explanations, is a minimum baseline where the skup (iS.Ketchup?) team should start, plus videos, glossaries. Clear error explanations, with cause examples and solution alternatives, references… Aint a question of idiomatic syntax/ linguistic differences or preferences. If you want historical reference look at Ken Iversons, “APL” a programming language, laid down in 1963 or so, a lot of the trail markers. Premise computer smarts can use embedded/ learned object parameters, states, encounters,… and can perform high order tasks , freeing the human, of housekeeping. When you have to perform object/ method trapeze-ing, and know the decision table, why not integrate the decision table into the method? (Not you, the skup-team). I think there’s too much self-adulation, gee, you cant get it with my simplistic examples, nya nya I’m smarter than you or making $ as a pathfinder. Btw, I see an excellent oppty to simplify the user Interface using ruby, within skup, and have a well selling product. Thx again. J

We must be clear. Teaching how to program in any language (including Ruby, C, Javascript, HTML, or any other language that SketchUp extensions use,) is not part of Trimble’s business model. Nor is it the responsibility of the SketchUp Team in Boulder.

There are plenty of books, tutorials and videos on how to program in Ruby and other languages. (We have covered this subject in other topic threads here.)

These are arguments that belong in the official ruby forum.

The SketchUp Team does not control Ruby. They cannot change the fundamentals of the Ruby language. You can take your complaints to

The SketchUp API is simply an extension that adds SketchUp specific modules and classes to the Ruby objectspace.

dan, first I appreciate your excellent explanations. But, We are talking business philo here. Products are made of some if not all non-company components. Simply pointing that out js counter productive to the buying customers and condascending. For example, a new car with 3rd party tires. The car mfgr should give some RELATED, COGENT info about the tires relevant to the cars usage (too), versus, go read another manual. E.g., tire pressure relative to weather. Possible wall damage events, … Think of SKUP and Ruby as a sticky product. Usability, ease of use, should be taken seriously by Skup inc or at least their MARKETING mavens, Examples (video and text) should illucidate this great product, e.g., here;s how we created a multifaced, 3D entity, select all its components, save it as a permanent component in “my library”, then retrieve multiple instances where it was “put” (instanced) according to a 2D table listing basic attributes such as location X,Y,Z, and simple/ “complex” (or compound) rotations (transformations), etc. :

No, WE ARE NOT. (This category is for Ruby API programming, maybe we should move this thread to the Corner Bar?)

You seem to be interested in changing the Ruby coding language, SketchUp’s fundamental API implementation, and the Trimble Development Team’s way of product management.

I am speaking of how things are now, from a pragmatic realist point of view, and the need to get tasks done with things as they are. (And BTW, stating facts is not condescending.)

I am not interested in arguing about fanciful things outside my control, as I do not work for Trimble.

I am also not interested in carrying on a long term argument, where I have to re-read the whole thread again every 10 months, to catch up. Therefore, I am “unwatching” this topic and I am done discussing this. It is just a waste of my time.