🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download
  • Manipulate text label attached to entity

    6
    0 Votes
    6 Posts
    734 Views
    A
    Approach with SelectionObserver: See the documentation: http://www.sketchup.com/intl/en/developer/docs/ourdoc/entities#add_text http://www.sketchup.com/intl/en/developer/docs/ourdoc/text component # be a reference to your component instance position = ORIGIN # or any other point in the component coordinate system direction = Geom;;Vector3d.new(0,0,1) component.entities.add_text(position, "The label text", direction) To find the text again, under the assumption the component contains no other texts: in a Selection Observer def onSelectionBulkChange(selection) return unless selection.count == 1 return unless selection.first.is_a?(Sketchup;;ComponentInstance) component = selection.first return unless component.name == "Specific name" text = component.entities.grep(Sketchup;;Text) # Do something with the text end As I understand your request, you just want to display information to the user, but you do not want to modify/edit the model file. I strongly suggest not to use the native selection tool and observers for this, because it would run always when the user uses the native Select Tool (with a different intention in mind), and observers run always if not properly attached and removed. Plugins should use observers as little as possible (in terms of time), namely only when the user explicitely launches the plugin. Approach with a SketchUp Tool: You could write your own tool instead, which allows you to draw your information to the screen, instead of "modeling" text by adding entities to the model. It is also much cleaner because the user can unselect your tool and use the native Select Tool without confusion. See for reference: http://www.sketchup.com/intl/en/developer/docs/ourdoc/tool http://www.sketchup.com/intl/en/developer/docs/ourdoc/view#draw_text http://www.sketchup.com/intl/en/developer/docs/ourdoc/pickhelper#best_picked linetool.rb example Create a class: module Sepultribe module SensorNodeInfoPlugin class SensorNodeInfoTool SPECIFIC_NAME = "Specific Name" def initialize @selection = nil @info = nil end def onLButtonDown(flags, x, y, view) pick_helper = view.pick_helper pick_helper.do_pick(x, y) item = pick_helper.best_picked return unless item.is_a?(Sketchup;;ComponentInstance) return unless item.name == SPECIFIC_NAME # Now you have the right component, store it in an instance variable. @selection = item # Fetch the info that you want to display (assuming you have it stored as attribute) @info = @selection.get_attribute("dictionary_name", "attribute_name", "") end def draw(view) return if @selection.nil? position3d = @selection.transformation.origin # or @selection.bounds.center position2d = view.screen_coords(position3d) # (You could also draw the bounding box of the selected component.) # Draw an arrow. vector = Geom;;Vector3d.new(20,-20,0) view.draw2d(GL_LINES, position2d, position2d+vector) # Draw the info. view.draw_text(position2d+vector, @info) end end # module Sepultribe # Add the plugin to the menu, only once when the file is loaded. unless file_loaded?(__FILE__) command = UI;;Command.new("Display Sensor Node Info"){ Sketchup.active_model.select_tool(SensorNodeInfoTool.new) } UI.menu("Plugins").add_item(command) end end # SensorNodeInfoPlugin end # module Sepultribe
  • Put forward drawings openGL

    14
    0 Votes
    14 Posts
    846 Views
    D
    Anton_S your code is very interesting (highlight_picked_body.rb), I have never used Start and stop operation inside a custom tool, I like the result, I am studying this code
  • Color changes with regard to distance from a surface

    3
    0 Votes
    3 Posts
    332 Views
    SkeeterdS
    Whew! Thanks a million TT! Had no idea that button was active unless sun/shadows was turned on. Didn't even think to try that. That did it. A simple fix indeed. Digging SU just a little more... I'll post this model to the forum once it's completed. I'd call it the Mother of all SU projects. 18 buildings and all the related parking lots, side walks, grounds, tress etc. Really TT, thanks for the fix!
  • Ruby: 3d align components

    5
    0 Votes
    5 Posts
    462 Views
    sdmitchS
    @kaas said: @sdmitch said: If you are willing to post or pm me a sample model and the plugin, I will be glad to see what if anything I can do with it. Hi Sdmitch, thanks for your offer. Jolran and I are already pm-ing about a solution so I think it will be already resolved. Max Great, but the offer is still good.
  • Ruby question: create faces from edges? Faces with holes?

    9
    0 Votes
    9 Posts
    2k Views
    tt_suT
    The issue is that edges = entities.add_edges [[30,0,10], [50,0,10], [50,0,30], [30,0,30], [30,0,10]] doesn't weld the start and end point. Therefore there are two vertices at the same 3d point that isn't welded. add_face(edges) require the edges to form a closed loop - the edges you have in this case just looks to be closed. It's unexpected, I agree, but changing the behaviour now might break existing extensions. But any reason for first creating edges and then creating the face from the edges instead of just creating the face with the points directly?
  • Units in the input value through the VCB

    3
    0 Votes
    3 Posts
    370 Views
    D
    Dan thanks for replying, I found a recommendation yours here http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=55722%26amp;p=505915%26amp;hilit=units+vcb#p505915 which led me to the article by thomthom http://www.thomthom.net/thoughts/2012/08/dealing-with-units-in-sketchup/ I only have problem for receiving angles values ​​with comma as decimal separator, then I am forced to use the following text_input.sub!(',','.') text_input.to_f.degrees I do not know if there is a better method
  • Issues with Scrambler

    6
    0 Votes
    6 Posts
    1k Views
    Dan RathbunD
    Karen.. this is a forehead smacker (so get your hand ready.) Standard Ruby has no idea what a scrambled rbs file is, or how to decrypt it. So the SU development team created a module method that could open, decrypt and then evaluate them. You need to use the Sketchup::require() module method. There are other issues with scrambling. The Ruby keywords __LINE__ and __FILE__ do not currently work inside scrambled rubies. (Fixed in SketchUp 2014+ using Ruby 2.0 or higher.) I'm am glad that you have decided to use your own filespace. It's only smart. I posted an example of doing this with scrambled rubies. See: [ code ] SketchupExtension and rbs rubies
  • Webdlg debugging on Mac using WebKit inspector

    8
    0 Votes
    8 Posts
    2k Views
    tt_suT
    Install Visual Studio Express (free). Then you can either attach it to SketchUp's process, or inject debugger; statement in your JS code to make the system prompt you to debug. You can then set breakpoints in Visual Studio and inspect variables and call stacks. I sometimes use a catch-all code like this to trigger the debugger on errors without having to inject debugger; around in the code: window.onerror = function(message, location, linenumber, error) { // Trigger an request to attach debugger. debugger; return false; };
  • HTML5 Canvas in Webdialogs

    3
    0 Votes
    3 Posts
    438 Views
    B
    Brilliant! Thank you so much - it's working fine now.
  • Unexpected result (closest_points)

    3
    0 Votes
    3 Posts
    322 Views
    D
    sorry for my silly mistake, thanks Sdmitch
  • Selection.add ??? possible?

    4
    0 Votes
    4 Posts
    387 Views
    tt_suT
    Was that a question on how? Or did you experience issues with Selection.add (because that is exactly the API method to do what you requested: http://www.sketchup.com/intl/en/developer/docs/ourdoc/selection#add)
  • UI exit ruby?

    4
    0 Votes
    4 Posts
    695 Views
    artmusicstudioA
    hi and thanx to both, @ tig: yes, i also use puts-tags to follow the code in the console , whit line-number-output to see, in which code -line the puts is. i will try out all the break, next etc. functions. thanx for this? and @tt_su yes, interaction with the viewport was exactly, what i hoped for, so i could inspect the geometry at any stage ot the running code. (break - inspect geometry - go on....). the rest is still tooooo 'high' for me, although i already 'speak' a bit ruby...-:) stan
  • Read and Write (update) problem

    12
    0 Votes
    12 Posts
    909 Views
    S
    Thanks to every one here (and also Thomas Thomassen) the work is now finished! https://www.youtube.com/watch?v=xQOgv2OedJM
  • How do I run send_action for a custom menu item

    4
    0 Votes
    4 Posts
    540 Views
    TIGT
    You can't use the script's code if it's inside an encrypted RBS, but if the Extension menu/toolbar-maker is in a RB, then you can read it to see what it's doing... You have to do some detective work... If we knew this 'secret' extension then we could comment more constructively
  • Puts inconsistency & machine epsilon management

    20
    0 Votes
    20 Posts
    2k Views
    Dan RathbunD
    There are some class level constant settings for the Float class. List them: Float.constants Example: Float::DIG 15
  • Full ruby installer

    14
    0 Votes
    14 Posts
    2k Views
    R
    It worked beatifully. The only thing I had to change was a line of code where I use 'angle_between'. I just created a temporary Vector3D and solved the issue. I had to switch to Marshal because files were getting too big (180MB) and it was taking 15 minutes just to save.
  • [solved] merging two triangle faces of a mesh-square

    4
    0 Votes
    4 Posts
    770 Views
    artmusicstudioA
    hi tt, to finish this topic, i learned how to identify a surface and handle its parts (faces) and now i can manupulate its elements, as needed. thanx to all in this topic for helping and ttheir ideas. stan
  • How to use special characters in filenames like æøå

    3
    0 Votes
    3 Posts
    327 Views
    R
    Hej Thom, Then it sounds like I have to switch to Sketchup 2014
  • Retrievin object's absolute height ??

    18
    0 Votes
    18 Posts
    1k Views
    jolranJ
    Dats true. But I don't understand why you opt to create a new Array for each edge instead of a ternary
  • How to save the model to a file?

    7
    0 Votes
    7 Posts
    447 Views
    Dan RathbunD
    @rvs1977 said: @sdmitch said: I use Sketchup 8.0.15158 - Maybe thats why...? Yes.. as I said above, prior to SKetchUp 2014, we had to make sure ENV["HOME"] was set ourselves (as I showed above.) Ruby needs it set.

Advertisement