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

    3
    0 Votes
    3 Posts
    337 Views
    F
    Thanks Anton_s! Even though I'm still trying to figure out what and how your code works it does work perfectly!
  • Sketchup to database

    2
    0 Votes
    2 Posts
    357 Views
    TIGT
    I've moved your post to the Developers' Forum. You are likely to get the attention you seek, and help relies to questions here... It is possible to write Ruby whch will read in a file, from that make geometry, and then export data back into a file... A few tips... There are some importer Plugin examples you should find and study... It's much easiest to use 'plain text' CSV rather than binary XLS etc... Obviously the file's exact format needs to be consistent and readily readable - usually points are make X,Y,Z one per line in the file, but if you want to define lines, then perhaps, X1,Y1,Z1,X2,Y2,Z2 - i.e. the line's [aka 'Edge'] start and end one per line in the file. You also need to consider the 'units' the file in in and how that translates to SketchUp - which always use inches as its base-units... There are also already some Plugin examples of 'cut-list'and similar exporters [CSV]...
  • Two-point perspective from API

    3
    0 Votes
    3 Posts
    622 Views
    tt_suT
    I'm afraid that's a known limitation. We have an issue written up for it though. I'll add a reference to this thread to it.
  • Entity Attribute !?

    9
    0 Votes
    9 Posts
    422 Views
    mtripleM
    thx u all. that was useful ill replay since i do some changes.
  • SecureRandom slow

    10
    0 Votes
    10 Posts
    630 Views
    jiminy-billy-bobJ
    @tt_su said: You just need something random enough. Using the hash of the component name might be good enough for your use. Current definition name and time should give you a different hash per component name per object. Yeah I was looking at something like that. But Dan's solution is simpler and seems so obvious! smack on the forehead
  • SU Gui toolkits

    5
    0 Votes
    5 Posts
    328 Views
    Dan RathbunD
    @billw said: Alas WxSU has not worked for a long time with Sketchup ... I would be more than happy if Trimble implemented something similar to wxsu. I looked into this recently. The issue is with WxWidgets (used by WxSU,) .. I think that the latest version for Ruby 2.x, is still unstable, and is not out of beta. (It might not even compile currently.) Even the old version has not been worked on in awhile. Another issue is that the top level window needs to be a WxWidgets class window, which the SketchUp app window is not. WxSU did a clunky "fix" by re-assigning the SketchUp app window to be a child window, of an invisible WxWdigets WxFrame. This can be done on Windows (at least XP,) but probably not on Mac.
  • PagesObserver.onElementAdded

    3
    0 Votes
    3 Posts
    241 Views
    K
    Thanks Dan I had finally figured that out and then I tried different observers since my post and I don't think the overhead is worth it. If the user forgets to move the dim to the dwg layer it only means there will be stray dim in other dwg scenes. I am thinking of adding a note when the dwg scene is first made to remind the user that added dim will need to be placed on the dwg layer. Keith
  • C SDK - How to get reference for the camera object(s)?

    7
    0 Votes
    7 Posts
    400 Views
    G
    Thank you for checking it.
  • Upgrading plugins to Ruby 2.0 for SketchUp 2014

    43
    0 Votes
    43 Posts
    7k Views
    tt_suT
    Your force encoding example will only work if the input text file (CSV) file is ISO-8859-1. ISO-8859-1 is all 8bit per character. However, if you open a file that is saved with UTF-8 encoding and it contains characters over the ASCII range (127) then there will be multi-byte characters - when you then force ISO-8859-1 encoding and convert that to UTF-8 you will mangle the characters. If you have no idea or control over the input data then I would try to use a try/catch approach of first reading the file in what is more likely for the file to be encoded in. If you get encoding errors thrown which you can catch and try the next likely encoding. You can then fall back to just reading it as binary: if RUBY_VERSION.to_f > 1.8 filemode << ';ASCII-8BIT' end File.open(file_name, filemode) {|file| file.seek(80, IO;;SEEK_SET) face_count = file.read(4).unpack('i')[0] } Look at these errors and see if they might be thrown: Encoding;;CompatibilityError Encoding;;ConverterNotFoundError Encoding;;InvalidByteSequenceError Encoding;;UndefinedConversionError EncodingError If you are not familiar with Unicode and how it's represented in byte data I would recommend reading up on that as well. The reason it has worked for you so far has probably been that you have had ASCII compatible data. UTF-8 is byte compatible with ASCII where it uses only one byte per character - but the moment you go outside the ASCII (US-ASCII to be precise) it get multibyte characters. For your testing purposes I would strongly recommend you test with non-english characters. For good measure make sure you go outside of European languages as well, try Japanese or Chinese for instance which might be four byte per characters.
  • [code] SketchupExtension and rbs rubies

    10
    0 Votes
    10 Posts
    4k Views
    Dan RathbunD
    WARNING: This is an OLD topic thread. The SketchupExtension class has been revised (at least) twice since this topic was written.
  • Override the alt-key in a class ??

    3
    0 Votes
    3 Posts
    236 Views
    fredo6F
    @artmusicstudio said: is it possible to override the native alt-function (menu-hi-lite) temporarily within a tool This is possible for ALT. You need to return true in the onKeyUp method for the case of key == ALT_MODIFIER_KEY. Actually, returning true seems to prevent bubbling. This is also a way to prevent characters to go to the VCB Fredo
  • How to load all RBS files ?

    8
    0 Votes
    8 Posts
    3k Views
    A
    thanks for the answer Pingpink. somebody opened a thread about your Plugin in the Plugins sections of Sketchucation just the other day. Can you please post more info there? http://sketchucation.com/forums/viewtopic.php?f=323%26amp;t=58694%26amp;p=534451#p534229
  • [Solved]Full-Screen Sketchup on Mac

    6
    0 Votes
    6 Posts
    482 Views
    D
    Oh well, thanks anyway guys
  • SU 2014 Validtiy Check issues

    16
    0 Votes
    16 Posts
    856 Views
    T
    @dan rathbun said: I remember that the layer name of 0 was changed from language localized names to "Layer0" for all language editions at some point. (We would think the validity check would fix this, in newer SketchUp versions.) Perhaps unicode characters are causing issues in layer names ? I'm wondering if the following code I'm using might be the cause? layers=model.layers layers.add (@frame) activelayer=model.active_layer=layers[@frame] layer=model.active_layer #code that places stuff on layer frame #goes here #at the end of this routine I reset layer # Reset layer back to default layer [0] layers = model.layers activelayer = model.active_layer=layers[0] layer = model.active_layer
  • Manipulate text label attached to entity

    6
    0 Votes
    6 Posts
    612 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
    547 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
    255 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
    381 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
    282 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

Advertisement