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?
Posts made by PatrickBEL
-
Component automatic placement
-
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
-
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
-
RE: [Code]Text label system
Hej TIG,thanks alot!!
I'm working on it now i'll post the result later. -
[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"
-> etcIm 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 </span><span class="syntaxdefault">AdressingTool<br /><br />def Start <br /> </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 </span><span class="syntaxcomment">#inputpoint will be replaced by the value of the center of the boundingbox<br /> </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 </span><span class="syntaxcomment">#Distance<br /> <br /> </span><span class="syntaxdefault">bb </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">BoundingBox</span><span class="syntaxkeyword">.new;<br /> </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 </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">| </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">) ; }<br /> </span><span class="syntaxdefault">boundb </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">bb</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">bounds<br /> center </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">boundb</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">center<br /> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">messagebox center<br /> <br /> mod</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br /> ent</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br /> txt</span><span class="syntaxkeyword">=</span><span class="syntaxstring">'Adress comes here'<br /> </span><span class="syntaxdefault">t</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">ent</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_text txt</span><span class="syntaxkeyword">,@</span><span class="syntaxdefault">inpp</span><span class="syntaxkeyword">,@</span><span class="syntaxdefault">vec<br />end<br /><br />end </span><span class="syntaxcomment">#end of Class AdressingTool<br /><br /> </span><span class="syntaxdefault">plugin_menu </span><span class="syntaxkeyword">= </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 adress"</span><span class="syntaxkeyword">) { <br /> </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 AdressingTool</span><span class="syntaxkeyword">.new } </span><span class="syntaxdefault"></span>