ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Rotate a component before place it with a key imput

    2
    0 Votes
    2 Posts
    979 Views
    Dan RathbunD
    @boom02 said: Do you guys think this is the right way? NO. The spacebar is pre-coded to activate the native SelectionTool. Many users are used to it this way, and do not want to change it. Those that have changed it, have done so for their own choice of command. Secondly, you cannot affect how the built-in place_component works as it is a native tool, most especially not when using the repeat mode. (Ie, there really is no way to trap the spacebar and prevent it from bubbling-up to SketchUp's shortcut handler.) The way it is designed, when not in repeat mode, is that once placed, the normal MoveTool is active, and it's hover rotate mode can be used. Just hover the MoveTool cursor over a the side of a component's bounding box, and 4 rotate handles will appear. Move to one of the handles and you'll see the cursor change to a protractor. I myself, also kinda miss the ACAD spin before place feature. @boom02 said: ... how can I get the key press from the user? The best way is inside a custom tool class written in Ruby. http://ruby.sketchup.com/Sketchup/Tool.html And you'd need to create a menu item pointing at a method object that rotates the selected object. Then that menu command can be assigned any shortcut, by users according to their own desires.
  • Trouble adding entity to component definition

    6
    0 Votes
    6 Posts
    2k Views
    Dan RathbunD
    A workaround we employ is to stick a temporary cpoint into the entities (at it's origin,) and then delete it later after we've loaded it up with geometry. The temp cpoint stops SketchUp's garbage collector from deleting the object.
  • Importing Bulk Attribute Values from CSV

    11
    0 Votes
    11 Posts
    2k Views
    H
    BTW, the answer to the original question was that input = UI.inputbox(@prompts, @defaults, @list, "Select Attribute Target") returns an array of values because typically the inputbox would present more than 1 option. In my case there was only one input or prompt so when I put input into set_result = Sketchup.active_model.set_attribute("dynamic_attributes", input, att_string.to_s ) I was actually sending in an array and thus setting a new key in the format ["whatever user put into inputbox"]. Even .to_s did not seem to help... set_result = Sketchup.active_model.set_attribute("dynamic_attributes", input.to_s, att_string.to_s ) The answer was to get the first item in the array like so: set_result = Sketchup.active_model.set_attribute("dynamic_attributes", input[0], att_string.to_s )
  • Observers WhishList

    59
    0 Votes
    59 Posts
    110k Views
    G
    @thomthom said: Would that be at the event of copying? Or when pasting? Can you describe the scenario you'd use it in? when copying i am trying to find a way to control the difusion of dynamic components if such an observer would be available, it would be easy to prevent unauthorized copies selection observer can be used, but it is less direct, and probably less efficient than an observer on copying more dynamic components would be created if there was a way to crypt them, just as ruby plugins
  • Uninitialized class variable

    5
    0 Votes
    5 Posts
    915 Views
    PixeroP
    Thanks, that worked.
  • Cleaning up memory in script

    3
    0 Votes
    3 Posts
    867 Views
    PixeroP
    Thanks.
  • Replace Several Textures?

    32
    0 Votes
    32 Posts
    4k Views
    sdmitchS
    I have PM'd you a possible solution to #7
  • How to create a selection window in a tool?

    2
    0 Votes
    2 Posts
    819 Views
    sdmitchS
    @ittayd said: I want to create a tool that allows to select several entities by either picking them or a selection window. But how do I draw the selection window? The "Select by Polygon" plugin you can find on my blog is an example of drawing the selection window then selecting the entities within it.
  • [Req] Dedicated SU onscreen keyboard.

    4
    0 Votes
    4 Posts
    1k Views
    J
    Maybe using something like autohotkey, I already use it to map some mouse functions to keyboard, here is a example of a full keyboard: https://autohotkey.com/board/topic/16891-ahkosk-onscreen-keyboard/
  • Fluid freehand

    15
    0 Votes
    15 Posts
    2k Views
    D
    the way it works in Preview.app would be good... [image: y5uE_in_preview.gif] john
  • Help please. How to get transformation for the face

    10
    0 Votes
    10 Posts
    2k Views
    A
    There it is, TBoy: class BoundsHighlighterTool def initialize @ip = Sketchup;;InputPoint.new @hovered_inst = nil @global_parent_tra = nil @global_bb = nil @labb_global_faces = [] # Faces for the local axes aligned bounding box. @gabb_global_faces = [] # Faces for the global axes aligned bounding box. @labb_global_edges = [] @gabb_global_edges = [] @labb_face_color = Sketchup;;Color.new(255,40,0,80) @gabb_face_color = Sketchup;;Color.new(0,40,255,80) @labb_edge_color = Sketchup;;Color.new(255,0,0,255) @gabb_edge_color = Sketchup;;Color.new(0,0,255,255) @edge_width = 3 end def deactivate(view) reset(view) end def onMouseMove(flags, x, y, view) @ip.pick(view, x, y) ip_path = @ip.instance_path if ip_path.empty? reset(view) return end inst = nil gptra = nil ip_path.each { |ent| break if !ent.is_a?(Sketchup;;Group) && !ent.is_a?(Sketchup;;ComponentInstance) if gptra gptra = gptra * inst.transformation elsif inst gptra = inst.transformation end inst = ent } unless inst reset(view) return end return if inst == @hovered_inst @hovered_inst = inst @global_parent_tra = gptra local_bb = @hovered_inst.bounds # Obtain corners of local axes aligned bounding box in global space lagc = [] for i in 0..7 lagc << local_bb.corner(i) end if @global_parent_tra lagc.each { |point| point.transform!(@global_parent_tra) } end @labb_global_faces = [ [lagc[0], lagc[2], lagc[3], lagc[1]], [lagc[4], lagc[6], lagc[7], lagc[5]], [lagc[1], lagc[0], lagc[4], lagc[5]], [lagc[2], lagc[3], lagc[7], lagc[6]], [lagc[0], lagc[2], lagc[6], lagc[4]], [lagc[3], lagc[1], lagc[5], lagc[7]] ] @labb_global_edges = [ lagc[0], lagc[2], lagc[2], lagc[6], lagc[6], lagc[4], lagc[4], lagc[0], lagc[3], lagc[1], lagc[1], lagc[5], lagc[5], lagc[7], lagc[7], lagc[3], lagc[0], lagc[1], lagc[2], lagc[3], lagc[4], lagc[5], lagc[6], lagc[7] ] # Create global axes aligned bounding box @global_bb = Geom;;BoundingBox.new() @global_bb.add(lagc) # Obtain corners of global axes aligned bounding box in global space gagc = [] for i in 0..7 gagc << @global_bb.corner(i) end @gabb_global_faces = [ [gagc[0], gagc[2], gagc[3], gagc[1]], [gagc[4], gagc[6], gagc[7], gagc[5]], [gagc[1], gagc[0], gagc[4], gagc[5]], [gagc[2], gagc[3], gagc[7], gagc[6]], [gagc[0], gagc[2], gagc[6], gagc[4]], [gagc[3], gagc[1], gagc[5], gagc[7]] ] @gabb_global_edges = [ gagc[0], gagc[2], gagc[2], gagc[6], gagc[6], gagc[4], gagc[4], gagc[0], gagc[3], gagc[1], gagc[1], gagc[5], gagc[5], gagc[7], gagc[7], gagc[3], gagc[0], gagc[1], gagc[2], gagc[3], gagc[4], gagc[5], gagc[6], gagc[7] ] view.invalidate end def draw(view) return unless @hovered_inst # Draw local axes aligned global bounding box view.drawing_color = @labb_face_color @labb_global_faces.each { |face| view.draw(GL_POLYGON, face) } view.drawing_color = @labb_edge_color view.line_width = @edge_width view.line_stipple = '' view.draw(GL_LINES, @labb_global_edges) # Draw global axes aligned global bounding box view.drawing_color = @gabb_face_color @gabb_global_faces.each { |face| view.draw(GL_POLYGON, face) } view.drawing_color = @gabb_edge_color view.line_width = @edge_width view.line_stipple = '' view.draw(GL_LINES, @gabb_global_edges) end def reset(view) return false unless @hovered_inst @hovered_inst = nil @global_parent_tra = nil @global_bb = nil @labb_global_faces.clear @gabb_global_faces.clear @labb_global_edges.clear @gabb_global_edges.clear view.invalidate return true end end # class BoundsHighlighterTool Sketchup.active_model.select_tool(BoundsHighlighterTool.new) This time we iterate through the InputPoint's instance_path and transform the bounding box of the deepest instance across all the the parent groups/component instances in the path.
  • Dynamic Component for holes

    4
    0 Votes
    4 Posts
    2k Views
    pilouP
    Perfect many Thx!
  • Push/pull (or drag) with increment ?

    3
    0 Votes
    3 Posts
    1k Views
    T
    Thank you ! Exactly as I wanted to be.
  • SketchUp Command Line Switches

    7
    0 Votes
    7 Posts
    6k Views
    TIGT
    SketchUp always includes its own Tools folder [and the nested Ruby folders] and your user Plugins folder in it load-path [ $:] You can include addition plugins folders in the load-path array, and any scripts in there will load as SketchUp starts. Fredo wrote a clever extension to do this for you. https://sketchucation.com/pluginstore?pln=000_AdditionalPluginFolders Read its More Info... pages for usage etc...
  • SKP 2017 - saving component to file via ruby

    3
    0 Votes
    3 Posts
    2k Views
    artmusicstudioA
    hi tig, thanx for replying, i just red your code and suppose, that every skp-file, you call, will be opened in the viewport and resaved as another version - correct? so it cannot be used as a background task within (under) a running sketchup session (maybe a parallel skp-session opens..... ), have to try it out later this evening. what is a big help for me, is the declaration <<ver=Sketchup::Model::VERSION_2016>>, i must have missed it in the api-doc. the rest is clear. but: so there is no way to declare the skp-version when saving a compo to a file, i guess... thanx stan
  • Pushpull face on a cube

    6
    0 Votes
    6 Posts
    1k Views
    TIGT
    As I already explained... And you can see this when it's done 'manually' too... If a rectangle face is wholly within another planar face and none of its edges are shared with any other faces, then the PushPull leaves a hole where the original face was. If a rectangle face has any edges shared with other faces - as in the case you have where the face is on the corner of the form and one edge has another non-planar face - then the PushPull can leave the original face behind in the new geometry...
  • Ruby Observer Existence Check

    6
    0 Votes
    6 Posts
    2k Views
    Dan RathbunD
    @tig said: You can set @obs = ... within a module, outside of any of its methods and that then persists thereafter. This is true because, a module is an instance of class Module. @hank said: Have not gotten very advanced with Classes etc. so just a simple module. The Class class is the direct child class of class Module. So classes inherit all of Module's functionality, and get a little bit of their own (ie, a few extra methods and the ability to have many instance copies of themselves, that can hold their own instance variable values.)
  • Copying files using &quot;ftools.rb&quot; library

    5
    0 Votes
    5 Posts
    1k Views
    Dan RathbunD
    @mgate said: require 'ftools.rb' > ... > folder = File.dirname( __FILE__ ) > resources = "Resources" > resource_name= "XXXXXX AT Template.skp" > resource_file = File.join(folder, resources, resource_name).tr("\\","/") > ... > Problem here. The "Resources" folder is not in a sub-folder of the "Plugins" folder, nor in a sub-folder of YOUR extension sub-folder (which should be in a sub-folder of "Plugins".) This should return the correct path: resource_path = Sketchup.find_support_file("Resources") The above script certainly creates the copy in the correct folder but SU crashes afterwards.[/quote] Do you get a BugSplat!, or is a Windows Error Report (WER) generated (ie, check Event Viewer) ? Secondly, your rescue clauses are not telling you what error is happening. Do something like this: begin # file operation rescue => e puts e.inspect # or UI.messagebox(e.inspect) else # change to more meaningful message; puts "file operation success!" end Thirdly, we used to tell users to run SketchUp as administrator because all users needed read and write permissions on folder in the SketchUp application's program path. (This can cause file drag and drop to stop working for SketchUp.) The alternative is to set permissions for SketchUp and all it's program sub-folders to allow all users full permissions.
  • Getting group's dimensions

    7
    0 Votes
    7 Posts
    1k Views
    S
    Thank you, I will work on this.
  • How to implement entity selection &quot;wizard&quot;

    5
    0 Votes
    5 Posts
    1k Views
    Dan RathbunD
    ... and new for SketchUp vers 2016 and higher is a rectangular window picking method: http://ruby.sketchup.com/Sketchup/PickHelper.html#window_pick-instance_method You should download the SketchUp Team's Examples extension to see how Tools are written. http://extensions.sketchup.com/en/content/example-ruby-scripts

Advertisement