Move or Transform group found using entityByName() script??
-
I'm trying to replace component by it's previously split array of groups stuctured to have the same form and dimentions. For more universal use I'm give all pieces[entities} the same name then I locate them using by given name and put them into an array using script from Lazyscript
def entityByName(entity_name="", ent_array=Sketchup.active_model.entities) #will look for entities with entity_name in ent_array, if entity_name is string it will return a single entity, if entity_name is an array of names it will return an array of all found if entity_name.class==Array x=0; entity_list=[]; ent_array.each{|ent| if (ent.typename=="Group" or ent.typename=="ComponentInstance") entity_name.each{|name| if(name==ent.name); entity_list[x]=ent; x+=1; end;} end;} return entity_list; elsif entity_name.class==String if entity_name=="FindText" x=0; entity_list=[]; ent_array.each{|ent| entity_list.insert(-1,ent) if (ent.typename=="Text") } return entity_list else ent_array.each{|ent| if (ent.typename=="Group" or ent.typename=="ComponentInstance") and ent.name==entity_name; return ent; end;} end end; end;
Now.. I checked UI and it finds those groups but I can't move the array using tranform! move! or transform_entities.
Ideally, i'd like to move all elements(groups)of the array simultaneously into position with rotation adequate to siluhette/eclipse the component. If it's not possible I could deal with some minor sacrifices.
Thanks in advance -
I don't quite understand what you want to do. You want to convert components to groups?
[off:2fgitufo]I see your code snippet uses
#typename
- it's an very slow method to use and you'd be better of replacing it. Read more here: http://www.thomthom.net/thoughts/2011/12/never-ever-use-typename/[/off:2fgitufo] -
I have 2 almost identical (visually) bodies, however one is a component and the other is exact same component but exploded->cut into pieces->which were than grouped (using method split()) so now I have the same shape but instead of 1 piece it consist of 256 groups now. I'd like find those groups (I can name them easily selecting them and using Entity info for multiple objects), put them into an array then locate 1-piece component erase it and put my shape consisting of 256 pieces in a place of a that solid single-piece component so I can then create some sort of a shatter effect.
I'm trying to work around an issue that Sketchyreplay has with entities that are created during simulation and doesn't include them correctly into output animation like split or emit.
I'm stuck with this problem for a week now and I need it for my project almost now.
If you could help me I would apreciate it. Please:) -
Okay, I managed to move entire array of groups however my project didn't save and because I did it after days of trial and error I can't now recreate my snippet but maybe someone knows how I can move that array of groups to another place (if I could get this first step again i should be able to get the rest). I'm pretty sure I used tranformation to get destination but can't figure it out.
Please help!!
Advertisement