Layout API "Hello World"?

Hello All. Could anyone direct me to a Layout API example that explains basic ruby script workflow? I am familiar with Sketchup API but just having trouble getting started. For instance, there does not appear to be a “Plugins” folder for Layout where I could place my scripts and start testing? Where should I put my scripts or how can I tell Layout where to look for them?

Thanks!

Because currently the LayOut API is non-live. This means it must run within SketchUp’s Ruby process.

So extension(s) that modify or create .layout files are (currently) SketchUp extensions.

Since there are no “live” LayOut application extensions, there can be no interface that displays messages to users such as “Hello World”.

1 Like

As Dan says the LayOut Ruby API is only available inside of SketchUp. The most trivial Hello word that just writes to the console would essentially be identical toa SketchUp Hello World.

A slightly more complex LayOut Hello World that creates a LO document and lets you save it out could look something like this.

leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label = Layout::Label.new("Hello World", leader_type, target_point, bounds)
doc = Layout::Document.new
doc.add_entity(label, doc.layers.first, doc.pages.first)
doc.save(UI.savepanel("Save Document", "", "test.layout"))

OK weird. Are there plans for for Layout API to go “live” or whatever where you could write scripts that worked without Sketchup?

And so I may be in “workaround” territory it sounds. OK, fine. Here is what I would like to do:

When my firm uses Layout to annotate drawings, there are probably 50 typical annotations we use I would like to create some sort of UI in Layout that could cycle through them.

I suppose I could l use the Label Tool’s ability to draw element data like Face Area into Layout. Seems super hacky so any thoughts?

We “suspect” so. But it hasn’t happened yet. Trimble’s SketchUp division does not publish roadmaps or future plans.

But because the LayOut APIs are currently file APIs that read and write .layout files only, you cannot author extensions that run within LayOut or modify it’s interface.

There is another topic thread around here about this very thing. Currently (despite requests) the LayOut Label tool is hard-coded to only access certain Attribute Dictionaries.

So you can use the SketchUp API to add attributes to the "dynamic_attributes" dictionary, and they’ll be available in LayOut to it’s Label tool. The other special dictionaries ("SU_DefinitionSet" and "SU_InstanceSet") are hard-coded to only access certain attributes, so any custom attributes will be ignored.

LayOut also has AutoText that can be added to your firm’s template.

Another option may be to bring in notes via tables linked to external spreadsheet files.

However, any UI that chooses these options would need to be done in a SketchUp extension, usually just prior to the LayOut document creation.

1 Like

Thanks Dan. OK, perhaps it’s not going to happen. What I envisioned was a text box/drop-down where you start typing and the text is matched a dataset. I think that would require something like the HtmlDialog in SU and could not be done through a something as blunt as a label hack. Spreadsheets are what we use now and it’s not the greatest because you have to cycle through so much to find what you need. Oh well! Thanks again.