sketchucation logo sketchucation
    • Login
    1. Home
    2. PatrickBEL
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    P
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 5
    • Groups 1

    PatrickBEL

    @PatrickBEL

    10
    Reputation
    1
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    PatrickBEL Unfollow Follow
    registered-users

    Latest posts made by PatrickBEL

    • Component automatic placement

      When i select a component in my component browser, sometimes sketchup places the component automatically, and sometimes it snaps to my mouse cursor, and i can place it wherever i want.
      Does somebody know where this "option" is?

      posted in SketchUp Discussions sketchup
      P
      PatrickBEL
    • RE: [Code]Text label system

      This is my code for now, and works perfect except for 1 thing.

      If i select more then one component, it doesn't work, it seems like it only runs one time the iteration.

      Just out of interest, i'm not sure why i'm using @@ now for each variable.

      Is there a way to adopt the layout of my text and change the size to "height" instead of point -size.

      require 'sketchup.rb'
      module PatrickBEL
      #UI.menu("Plugins").add_item("Add address"){Sketchup.active_model.select_tool(self;;AdressingTool.new())}
      submenu = UI.menu("Plugins").add_submenu("Adressing")
          submenu.add_item("Add address"){Sketchup.active_model.select_tool(self;;AdressingTool.new())}
          submenu.add_item("Settings"){self;;AdressingTool.dialog()}
      
        class self;;AdressingTool
           @@adr= 1
           @@offset= 1
           @@univ='A'
           @@count= 0
           @@vec= [0,0,0]  #Distance
         def initialize()
                      model=Sketchup.active_model
          		ent=model.active_entities
           
      	bb = Geom;;BoundingBox.new
      	Sketchup.active_model.selection.each {|i|
                      Sketchup.active_model.start_operation('AdressingTool')
      		bb=i.bounds
                      @@txt =@@univ + "." + @@adr.to_s
                      @@adr = @@adr + @@offset
                                     
      		pt=bb.max
      
          		t=ent.add_text @@txt,pt,@@vec
                      t.display_leader = False
                      Sketchup.send_action("selectSelectionTool;")
      		}
                      Sketchup.active_model.commit_operation
         end
         def self.dialog()
              results=inputbox(["Start Adress; ","Offset Number; ","Universe; ","Adr-posx;","Adr-posy;","Adr-posz;"],[@@adr, @@offset, @@univ, @@vec[0],@@vec[1],@@vec[2]],"PatrickBel-AdressingTool")
              return nil unless results ### i.e. the user canceled!
              @@adr, @@offset, @@univ, @@vec[0],@@vec[1],@@vec[2] = results
         end
       end#class
      end#module
      
      posted in Developers' Forum
      P
      PatrickBEL
    • RE: [Code]Text label system

      Hej, This is what i got for now.
      It works as should but now i need some improvements.
      -I would like to have a gui or a data input, where i can change the adr,offset,univ values
      I found some information about making input dialogs and so but im not really sure where to put it.

      -the general worflow of the tool could be.
      Plugin menu 1 item, 2submenus: Adress and Adress options.
      select component, run by shortcut Adress (label gets placed)
      select next component, run by shortcut Adress (incremented label gets placed)

      The problem now is that the AdressTool doesn't "quit" automaticly to go back to selection mode. so i can select the next component and run the tool again.

      require 'sketchup.rb'
      module PatrickBEL
      #UI.menu("Plugins").add_item("Add address"){Sketchup.active_model.select_tool(self;;AdressingTool.new())}
      submenu = UI.menu("Plugins").add_submenu("Adressing")
          submenu.add_item("Add address"){Sketchup.active_model.select_tool(self;;AdressingTool.new())}
      
        class self;;AdressingTool
           @@adr= 1
           @@offset= 5
           @@univ='A'
           @@count= 0
         def initialize()
      
              vec= [10,10,10]  #Distance
      	bb = Geom;;BoundingBox.new
      	Sketchup.active_model.selection.each {|i| 
      		bb=i.bounds
                      @@txt =@@univ + "." + @@adr.to_s
                      @@adr = @@adr + @@offset
                                     
      		pt=bb.max
                      UI.messagebox(@@txt)
                      model=Sketchup.active_model
          		ent=model.active_entities
          		t=ent.add_text @@txt,pt,vec
      		
      		}
         end
       end#class
      end#module
      
      posted in Developers' Forum
      P
      PatrickBEL
    • RE: [Code]Text label system

      Hej TIG,thanks alot!!
      I'm working on it now i'll post the result later.

      posted in Developers' Forum
      P
      PatrickBEL
    • [Code]Text label system

      Hej, i'm new to ruby but i'm trying to make an label/adressing system.

      I would like to make a tool when i select a component and i run the tool (by shortcut), it places an text label at a fixed position relative to the center of the component or at the right-front-upper corner of the boundingbox.

      next step in my todo list is that the textlabel will be automatically increasing.

      workflow of my tool should be:
      ->select component
      -> run tool
      -> label gets placed "1"
      -> select next component
      -> run tool
      -> label gets placed "2"
      -> etc

      Im not asking for a complete ready code, but ive got some problems with taking of:)

      heres wat ive got for now, but the issue i have now is that the boudingbox is not working

      <span class="syntaxdefault"></span><span class="syntaxkeyword">class&nbsp;</span><span class="syntaxdefault">AdressingTool<br /><br />def&nbsp;Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">@</span><span class="syntaxdefault">inpp</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">10</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">10</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">10&nbsp;</span><span class="syntaxcomment">#inputpoint&nbsp;will&nbsp;be&nbsp;replaced&nbsp;by&nbsp;the&nbsp;value&nbsp;of&nbsp;the&nbsp;center&nbsp;of&nbsp;the&nbsp;boundingbox<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">@</span><span class="syntaxdefault">vec</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">10</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">10</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">10&nbsp;&nbsp;</span><span class="syntaxcomment">#Distance<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">bb&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">BoundingBox</span><span class="syntaxkeyword">.new;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each&nbsp;</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">|&nbsp;</span><span class="syntaxdefault">bb</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">bounds</span><span class="syntaxkeyword">)&nbsp;;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">boundb&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">bb</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">bounds<br />&nbsp;&nbsp;&nbsp;&nbsp;center&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">boundb</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">center<br />&nbsp;&nbsp;&nbsp;&nbsp;UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">messagebox&nbsp;center<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;mod</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br />&nbsp;&nbsp;&nbsp;&nbsp;ent</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br />&nbsp;&nbsp;&nbsp;&nbsp;txt</span><span class="syntaxkeyword">=</span><span class="syntaxstring">'Adress&nbsp;comes&nbsp;here'<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">t</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">ent</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_text&nbsp;txt</span><span class="syntaxkeyword">,@</span><span class="syntaxdefault">inpp</span><span class="syntaxkeyword">,@</span><span class="syntaxdefault">vec<br />end<br /><br />end&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#end&nbsp;of&nbsp;Class&nbsp;&nbsp;AdressingTool<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">plugin_menu&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Plugins"</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Add&nbsp;adress"</span><span class="syntaxkeyword">)&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">select_tool&nbsp;AdressingTool</span><span class="syntaxkeyword">.new&nbsp;}&nbsp;</span><span class="syntaxdefault"></span>
      
      posted in Developers' Forum
      P
      PatrickBEL