💡 LightUp 7.1 | SketchUp's only real-time renderer that uses object-based rendering Download Trial
  • 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...

    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

  • Beginning Ruby - Array and other Questions

    5
    0 Votes
    5 Posts
    1k Views
    TIGT

    You can't rely on the ordering of a selection or an entities collection.
    Also you should never 'loop' through a selection or an entities collection, IF your code will affect the selection or collection - since it's references will 'shift' - use .to_a to free it as an array if you must do this...
    If you are adding several faces you make a simple empty array at the start:
    faces = []
    Then every time you make a face you can add that into that array.
    ... face = ... faces << face ...
    Later on you can access the faces array and its ordering will remain constant.

    You can only add geometry into an entities context - so that's either the model.entities [the lowest base level - even if not currently active], model.active_entities [current active context - which might be any collection], or any group.entities or definition.entities ...

    In passing, a group is just a special subset of a component.
    They both have a definition [so does an Image, but we'll not go there yet].
    A definition can have instances - placed into some entities context.
    A component definition can have several instances - changing one changes the others.
    You can make an instance unique so that editing does not affect its relatives.
    A group definition can have several instances, BUT editing one of them automatically makes it unique.
    When iterating a definitions collection you can filter its members using defn.image? and defn.group? to choose or avoid those types...

  • Erratic Duplication of Dynamic Components?

    3
    0 Votes
    3 Posts
    932 Views
    H

    Thanks @pcmoor I see what you are saying...

    The WALL DC has only dumb objects in it with no parameters.

    The OPENING DC has sub objects that use parameters.

    But this seems insane! You mean, the second you take advantage of parameters for your sub-objects you loose the ability to have central command of your DCs?!!!

    Perhaps you can explain your modeling techniques more? So you have a DC you copy around a bunch of times the explode it? Doesn't that kill any link you have to the original definition?

  • Polygon Positioning Tool

    13
    0 Votes
    13 Posts
    2k Views
    Dan RathbunD

    @medeek said:

    ... so I went back to my basic Windows Notepad, ...

    How do you know what encoding it saves the file it ?
    How do you know what type of line ending characters it uses ?

    These are things easily set with a real code editor.

    In addition code editors use color lexing to help you spell keywords correctly, match up the begins and ends of code blocks, etc. They also can use autocomplete features to help fillout method calls.

  • Boolean Subtraction or ???

    12
    0 Votes
    12 Posts
    2k Views
    medeekM

    I'm still digging through the code you sent me. It may take a week but I will attempt to figure out how this actually works. Its amazing how much you are able to compress into such a small body of code.

  • Need some development help.

    9
    0 Votes
    9 Posts
    2k Views
    S

    Wow! okay. This is totally awesome. This is quite a few levels above what I am capable of writing. This may take me like a week just to figure out. Sdmitch, you have saved me hundreds of hours of treachery. I want to buy you a beer, but I think you deserve a whole keg. This is way better then what I was plugging away at. Tig had got me thinking in the right direction about what I was trying for better ideas, and I had a feeling bounds was the answer to locating the foobar. I changed line 65 to some regex (=~/^[Ff]oo/) I learned from Tig back in the day to solve for a couple foos that were made unique and I left out the selection bits. This should be the example to anyone trying to get components out of their parents and gathered into their own.

    I want to thank the community here for being so awesome and living up to the name Sketchucation. I have learned so much from guys like Dan Rathbun, Thom Thom, TIG, sdmitch and too many others to list.
    Thanks & Cheers!

  • How to retrieve the version of the model

    2
    0 Votes
    2 Posts
    810 Views
    TIGT

    You need to read in the first part of the binary file SKP and see what version it says...
    ໿SketchUp Model೿{17.0.18899}䖯挢べ仪躯蘚䆤寸ÿ...

    In Ruby try something like this:

    vv=File.open(skp_path, 'rb'){|f| f.read }.unpack('m*').pack('m').gsub(/SketchUpModel/,'').to_i.to_s;if vv[0].chr=='1';v=vv[0].chr+vv[1].chr;else;v=vv[0].chr;end

    skp_path is the full path to the SKP you are trying to find the version of.
    vv is the long version number, as a string [e.g. "17018899"]
    v is the short version number, as a string [e.g. "17"]
    If you want more details parse vv differently...

  • Copy a Group within a Component in Ruby, preserve location

    8
    0 Votes
    8 Posts
    2k Views
    Dan RathbunD

    @hank said:

    **@Dan Rathbun:**I am just using the layer as an easy selector for the groups I want within the component.

    This is fine. Ie, using the layer property as a filter.

    @hank said:

    Do you recommend another way?

    I recommend rereading what I wrote. It was just general information (triggered by incorrect terminology you chose to use in an earlier post.)

Advertisement