sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Move or Transform group found using entityByName() script??

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 112 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L Offline
      lumianti
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        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]

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • L Offline
          lumianti
          last edited by

          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:)

          1 Reply Last reply Reply Quote 0
          • L Offline
            lumianti
            last edited by

            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!!

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement