Selective component explode
-
@chris fullmer said:
Try that and let us know how it goes,
ChrisSorry for the delay
here is the model
the component to explode is named KLC1-
it contains KLC1 (that's why i need to explode it)
i tried the code you suggested
it doesn't help on my computer (it freezes the computer)
exploding components seems to be a dangerous pratice in sketchup
-
@tig said:
I'd approach it differently...
n='KLC2-';m=Sketchup.active_model;m.start_operation('x',true);m.definitions[n].instances.each{|i|i.explode};m.commit_operation;
This one-liner, copy/pasted+<enter> in the Ruby Console explodes all instances of the component definition that is named 'n', it's one step undo-able... It will explode locked instances too - to avoid that use
i.explode unless i.locked?
instead... If there is no matching definition named 'n' you get an error message... It ignores all other definitions and instances so will be as quick as it can.When exploding a container the length of time it takes depends on the number of objects in it AND in its context, since Sketchup has to decide about intersections etc with all of them mixed together...
i copy/pasted the code.
It seemed to give a result, lines were scrolling in the ruby window
but it never ended, i had to force sketchup to stopmaybe i got something wrong somewhere...
thank you anyway for trying
-
@dan rathbun said:
@glro said:
e.definition.name=="**KLC2-**"
Is "
**KLC2-**
" a prefix that appears at the beginning of several definition names ??If so your logical test needs to use a regular expression, thus:
if e.definition.name =~ /\A(KLC2\-)/
... which returns
nil
if there is no match, (and evals tofalse
,) ... or if there is a match, it returns the zero based index of the match (which evals astrue
.)The pattern
\A
matches the at the beginning of the string only, so in this case the only valid index position that can be returned (for a match,) is0
.the component name in the example is KLC1-, it is not a prefix; just to make the difference with KLC1; the component embedded in it
-
Make a small SKP with a few components in it - one named 'KLC2-'.
Then run my one-liner [with any typos corrected - original is now fixed!].
It should not go into a loop...
Report Console errors, if any... -
this is what i typed in the ruby console
n='KLC1-';m=Sketchup.active_model;m.start_operation('x',true);m.definitions[n].instances.each{|i|i.explode};m.commit_operation;
it does make a loop...
this a shot of the ruby console, but it never ended, i had to force sketchup out
-
What does
m.definitions[n]
return assuming you define 'n' and 'm' as partial code beforehand... -
The model you provided, is that the whole model that you are working with or just a portion? The first code I posted completed in 2 seconds on that model, so I'm hoping that is only a small portion of a much larger model?
-
Works fine for me too, and explodes all 122 instances in a few seconds, using my code !
-
Geo - make certain the Outliner window is closed, and try again. Then disable that SketchStruct plugin and try again.
-
@chris fullmer said:
The model you provided, is that the whole model that you are working with or just a portion? The first code I posted completed in 2 seconds on that model, so I'm hoping that is only a small portion of a much larger model?
no, it is the whole model
the problem must be with my computer
i shall try to find out
-
Ahh, that's good to know! Definitely try disabling other plugins like Jim mentions.
-
@jim said:
Geo - make certain the Outliner window is closed, and try again. Then disable that SketchStruct plugin and try again.
you solved my problem !
I deleted sketchtruct and both TIG and Chris did the job in a few seconds...
How did you guess it was coming from sketchtruct?
This shows how much your "plugins quarantine" idea may help to solve plugin problems...
Thank you
-
Great job Jim!
-
-
@glro said:
How did you guess it was coming from sketchtruct?
Lucky guess, but the Ruby Console gave a bug hint...
Advertisement