SketchUcation Premium Membership

 

 

[HowTo?] Edit Components (or change "active level")

[HowTo?] Edit Components (or change "active level")

Postby MarcioAB » Tue Dec 02, 2008 3:52 pm

Now, on SU7, that one can get the full "genealogical instances path" from your current "active level" up to the model level ( with model.active_path ).
How can I re-position my "active level" in one particular instance of this path (kind of "edit level") ? Example:

print model.active_path
#<Sketchup::ComponentInstance:0x01><Sketchup::ComponentInstance:0x02><Sketchup::ComponentInstance:0x03>

That means my current "active level" is instance 0x03.
How can I move up one level using Ruby API to make my "active level" at instance 0x02 ?

Thank you


PS1: It could be a pair of APIs like this:

model.get_active_path ( exactly the same as model.active_path)
model.set_active_path(n) where n is the number of "levels" to go up.

In the example above, model.set_active_path(1) will move the "active level" to
#<Sketchup::ComponentInstance:0x01><Sketchup::ComponentInstance:0x02>


PS2: Today I'm using the OUTLINER to get positioned in a particular "active level". How can I do the same using Ruby API ?

Thank you
Marcio
MarcioAB
 
Posts: 50
Joined: Mon Oct 20, 2008 1:45 am
Location: Sao Paulo (23:37 S 46:38 O)

Re: [HowTo?] Edit Components (or change "active level")

Postby Matt666 » Tue May 19, 2009 11:44 am

Hi!
I am also intersted by this request... How can you set active path to a defined componant instance?
Frenglish at its best !
My scripts
Matt666
 
Posts: 829
Joined: Wed Dec 05, 2007 8:38 am
Location: 48.1184, -1.675
Name: Matt

Re: [HowTo?] Edit Components (or change "active level")

Postby thomthom » Tue May 19, 2009 11:46 am

Don't think there is one... :(
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17545
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [HowTo?] Edit Components (or change "active level")

Postby Jim » Tue May 19, 2009 11:48 am

Sounds like model.close_active is what you're looking for. You can "move up", but not dig deeper.

http://code.google.com/apis/sketchup/do ... ose_active
Jim
Global Moderator
 
Posts: 4126
Joined: Mon Nov 12, 2007 10:13 pm
Location: NEOH
Name: Jim
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: other
Level of SketchUp: Intermediate

Re: [HowTo?] Edit Components (or change "active level")

Postby Matt666 » Tue May 19, 2009 12:21 pm

Yes I know this method... But not its opposite! :(
Frenglish at its best !
My scripts
Matt666
 
Posts: 829
Joined: Wed Dec 05, 2007 8:38 am
Location: 48.1184, -1.675
Name: Matt

Re: [HowTo?] Edit Components (or change "active level")

Postby TIG » Tue May 19, 2009 12:31 pm

model.close_active ### will jump you up one 'level' out of the current edit session.
### You can only go in the direction of the base model...
### You can repeat x(model.active_path.length) to close the edit back to the base model 'level'.
### Alternatively...
model.active_path[model.active_path.length-2] ### to get up 1 level, or use -3 for 2 levels etc...
### All of these physically close any current edit sessions...
### If you just want to do something with the entities found at a particular 'level' then just use...
parent=model.active_path[model.active_path.length-2]
### i.e. the container of the current edit session's instance/group
parent_entities=parent.definition.entities if parent.typename=="ComponentInstance"
parent_entities=parent.entities if parent.typename=="Group"
### etc... there's no need to close edits etc, just specify the actual entities-set to work on...
TIG
User avatar
TIG
Global Moderator
 
Posts: 13919
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Need Authorised SketchUp Training by experts in various disciplines? Check out our Training details.

Ad Machine
Robot
 
Posts: 2012


Return to Developers' Forum

Who is online

Users browsing this forum: takes5, tiazu and 4 guests