Call an Extension Programmatically?

Is it possible? Say, for example, you have a script were you do a few things then upon completion, you want to activate TIG’s SectionCutFace Tool to prompt the user to create a section?

SectionCutFace is encrypted…
You could poke about in the various modules and methods, and test some examples…
e.g.

TIG::SectionCutFace.new() if TIG::SectionCutFace.ok()

So if a section-plane is preselected the tool runs…

Don’t wrap it in a commercial Extension !

1 Like

Building on @TIG’s point, a SketchupExtension instance registers various metadata with SketchUp’s ExtensionManager object when it loads. That metadata includes the path to the so-called “outer .rb file” that sets up the extension to run. But that outer file can do almost anything and can name its classes and modules any way the author chooses. The ExtensionManager has no idea how the extension actually works. Without inspecting the source code, you can’t know how to get a new instance object to attempt to activate it, and if the source is encrypted you can’t (legitimately) inspect it! TIG generously dropped a hint for this specific case, but you can’t conclude anything general from it.

1 Like

OK, sounds like a soft NO. Thanks, its back to the drawing board.

BTW, I would never consider it for something commercial. I write little scripts here and there to help with my own productivity. As an architect, there are many things I do OVER and OVER.

TIG, I would love to see under the hood of SectionCutFace to learn how it works but I understand its IP!

if the ‘tool’ your after has menu item and a command object, and has a shortcut key assigned to it…

you can use cliclick or mousetools [bin scripts for a mac] to send those keys…

if you want I’ll PM you an example for an AC type ‘Move Copy’ I made recently…

all it does is activates ‘Move Tool’ and then sends to invoke copy…

john

Bam! Yes please! That is exactly what I was wondering.

I am ok with it being a little hacky because I can control the user environment.

Hi John, can you please help me activating the move tool from my extension. A code sample would work.
@hank I would appreciate if you can share it, John is not active in the forum for a while now.

Sketchup#send_action class_method

Sketchup.send_action("selectMoveTool:")
1 Like

@dezmo is there a way I can activate my move tool at a specific point.
Currently, I have a model which will be created by clicking on an ‘add’ button from a menu option. I want to create the product at the current cursor location and activate the move tool so that the user can move around and place the model at the proper location(Similar to what happens when you create a model from the 3D warehouse)

For that purpose there is a special method already:
The

Model#place_component instance_method

places a new component in the Model using the component placement tool.

e.g:

model = Sketchup.active_model
path = Sketchup.find_support_file "Bed.skp",
  "Components/Components Sampler/"
definitions = model.definitions
componentdefinition = definitions.load path
model.place_component(componentdefinition, true)

place_comp

@anuragjoshi This might interest you …

[code] undoable place_component() "MoveTool" clone

1 Like