Script that would draw a line based on file names

Would it be possible to write a script that would draw a line (in a certain location ) for every layer that is in the file?

Can you explain what it is you are trying to accomplish?

Please explain more. From your topic title and text I don’t understand what you mean. It is certainly possible to add edges to a model using the Ruby API and it is likewise possible to read many kinds of input, but I don’t understand what layers have to do with file names.

Thanks! I would like to:

  1. take an existing file that I have. There are some 30 layers in this file.
  2. Clear it out of everything in there.
  3. Have some gizmo that would draw one 10ft line 2ft apart for each different layer

Most of that doesn’t sound difficult. but the devil is in the details. E.G.

Located where? Oriented how? Loose edge or grouped (so it won’t interfere with other geometry)? Should the group get the previous tag?

each line is 10ft long and is a simple group
The first line is placed at 0,0,0, and is placed on the 1st layer (i am in pro18)
The 2nd line is placed at 0,2ft,0 , runs along the red axis and is placed on the 2nd layer

etc and so on. As simple as possible!

Would that be hard for me to figure out how to do? (This would be my first script!)

This would not be hard for someone with experience in Ruby programming and good familiarity with the SketchUp Ruby API. However, any SketchUp Ruby extension is potentially a major learning exercise for a noob.

How much programming experience do you have? Have you ever tried Ruby? Have you looked at the SketchUp Ruby Api documentation? There’s a lot to pick up and potential frustration if you try to shortcut the learning process. @DanRathbun is our forum goto guy for links to resources about these things.

1 Like

Thanks! Yes, I need to start with some basic instruction and this would be my personal project to learn through. How steep is the curve? (meaning… could i learn this in a weekend or a week or…???) Thanks!

Alas, that depends so strongly on your background and ability that I can’t even begin to make an estimate. A weekend seems overly optimistic!

1 Like

Thanks for sharing with me! I will seek out some intro training… :slight_smile: :grinning:

1 Like

Please reassign this topic to the Ruby API subcategory [thanx Steve], and see the pinned Ruby Learning Resources lists at the top of that subcategory.

There are several topic threads in that category covering discussion on learning to code for SketchUp Ruby.

P.S. … you said …

FYI, …

SketchUp layers (aka tags) are not geometric entity collections. They are display property sets that the display engine uses to decide what and how objects and entities will be rendered. So you don’t “place on” a layer, … you assign an entity’s or object’s layer property to point at one of the model’s layer objects.

And, I will suppose that by now you know that SketchUp has edges not lines. In the API they are different things. Lines are virtual (non-model objects), have a position and a vector describing their direction, but are infinite in length in both directions.

1 Like

Thank you!