sketchucation logo sketchucation
    • Login
    1. Home
    2. johnwmcc
    3. Topics
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    J
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 18
    • Posts 105
    • Groups 2

    Topics

    • J

      TIG's Free Rotate crashes SU2020 and 2021

      Watching Ignoring Scheduled Pinned Locked Moved Plugins
      5
      0 Votes
      5 Posts
      3k Views
      TIGT
      With so much legacy stuff that's years old I don't have time to fix them unless it's obvious whats wrong and/or it's 'paid' ! Often the younger coders like Eneroth have made similar tools that are better anyway... PS: I just tried my FreeRotate in v2021 on my PC and it worked fine ! I can't test it on a MAC as my old-thing can't upgrade Catalina to let v2020 or newer be installed...
    • J

      Updated parametric.rb ruby script

      Watching Ignoring Scheduled Pinned Locked Moved Plugins
      1
      0 Votes
      1 Posts
      812 Views
      No one has replied
    • J

      Starting a new Ruby Tool Extension

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      13
      0 Votes
      13 Posts
      2k Views
      thomthomT
      The example focused on writing a tool. Tool are so complex that in an example I didn't want to muddle everything else into it. In the examples I'm writing I was a separate "tutorial" that describe in detail how to structure the folders and register the extension and add a menu. Toolbars and localization are good separate topic - each deserving their own attention. I had thought I'd put it on GitHub once it was more fleshed out - but maybe I should try to put out the WIP since we already have a topic on this going here. As for parenthesis - that's a code style and that is something people have to pick for their own. I used explicit parenthesis myself because I was familiar with other languages that always required them. But in Ruby this isn't the norm. I found that it was easier to just use normal convention for the language - as sharing code and adopting example code required less work. For Ruby code I use the GitHub style guide which seem to be the de-facto standard. IDE's normally base their inspection rules on this and you'll hear a lot of squawking if you use a different style - unless you spend the time to reconfigure the style rules.
    • J

      Back edges and scenes

      Watching Ignoring Scheduled Pinned Locked Moved SketchUp Discussions sketchup
      6
      0 Votes
      6 Posts
      306 Views
      Dave RD
      You won't get prompted to give the style a new name although that could be a nice new feature to request. It just appends a number to the style. I would suggest that you keep all of the style options ticked normally and only untick boxes for special cases.
    • J

      Returning a value from a Class method

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      17
      0 Votes
      17 Posts
      738 Views
      Dan RathbunD
      @johnwmcc said: If you are storing Point3d objects, would you need @contents.to_a first, before .max.y or min.y? The min and max methods come from the Enumerable mixin module. Enumerable is mixed into Array, but not Geom::Point3d, nor Geom::Vector3d. To see what modules may be mixed into a class, use *Classname*.ancestors So to answer the question, yes, or if using your own collection class, you might mix in the Enumerable module into it. @johnwmcc said: It does, for me. It was intended to select out the y coordinate (a scalar) from the point coordinates. ary = [pt1, pt2, pt3, pt4, ... ] To select the point which has the minimum y value, from an array of points, do this: miny_pt = ary.min {|a,b| a.y <=> b.y } To select the point which has the maximum y value, from an array of points, do this: maxy_pt = ary.max {|a,b| a.y <=> b.y } ... then get your thickness: thickness = maxy_pt.y - miny_pt.y To translate: [ruby:247d5h9w]ary.max {|a,b| a.y <=> b.y }[/ruby:247d5h9w], into plain English: "iterate [ruby:247d5h9w]ary[/ruby:247d5h9w], each loop compare the current member ([ruby:247d5h9w]a[/ruby:247d5h9w])'s y value, against the next member ([ruby:247d5h9w]b[/ruby:247d5h9w])'s y value, and return the member that resolves to the maximum." The comparison is defined using Ruby's comparison operator, [ruby:247d5h9w]<=>[/ruby:247d5h9w]. Remember that the entire member is returned, so later you still need to ask for just the y value. @johnwmcc said: I wasn't sure if the [ruby:247d5h9w].x[/ruby:247d5h9w] and [ruby:247d5h9w].y[/ruby:247d5h9w] methods would work on arrays, but they seem to in my example code. Because the SketchUp API adds those methods to the Ruby Array class. (It is part of making Ruby arrays compatible with API points and vectors.) @johnwmcc said: I'm unclear about the near-but-not-complete equivalence between SU [ruby:247d5h9w]Point3d(x, y, z)[/ruby:247d5h9w] and [ruby:247d5h9w]Array[x, y, z][/ruby:247d5h9w]- it seems I can use either a lot of the time, but not quite always! Read the API regarding how it adds to Array class: http://www.sketchup.com/intl/en/developer/docs/ourdoc/array
    • J

      Weird face normal behaviour in rotated component

      Watching Ignoring Scheduled Pinned Locked Moved SketchUp Discussions sketchup
      7
      0 Votes
      7 Posts
      2k Views
      J
      Absolutely no offence taken - it was indeed in my (mis)understanding of what I was seeing. It is now much clearer, and your clarification just sets out very well what I clumsily sort-of-worked-out by experiment and observation in a variety of cases. I think I was further confused when Chris's plugin seemed to be getting the same unexpected results as I was, and by a rotation I was doing of a view.draw_polyline about the reported face.normal which seemed to be visually wrong - it was actually rotating the polyline in the face plane, about an axis apparently NOT visually normal to it! However, since the only thing that was really bothering me was that when I tried to do a view.draw_line for the normal, it was in the wrong direction, I now understand why, and have fixed it. Thanks again for your helpful comments. Has anyone ever done a Tutorial about programming Ruby Tools in SU? I haven't found one, and have done almost all my learning from reading the sample code for CLineTool, and reading and re-reading the API documentation, which is very thin on real world examples and sample outputs. It's been hard work, though ultimately I've got something that now works for rectangular profiles. Next challenge - to extend it to arbitrary profiles of mouldings. A bit like a simpler version of the Profile Builder plugin from Dale Martin and SMustard - indeed, perhaps in comparison just a poor thing, but mine own, as one of Shakespeare's characters says.
    • J

      Request for help in developing a new Tool

      Watching Ignoring Scheduled Pinned Locked Moved Plugins
      12
      0 Votes
      12 Posts
      571 Views
      sdmitchS
      @johnwmcc said: Thanks for the suggestion. Unfortunately, it reports just the same normal as face.normal - off at an angle from the face, but along one axis to which the face is NOT normal geometrically! I shall look again at the sequence of inserting and transforming the face into the component definition - I'm now pretty sure that the problem lies in the create_geometry method, where I draw the face, insert it into a component definition, then transform it to the required position. Doing that is somehow seriously distorting where the component thinks its face normals point - not normal to the physical face! If you are picking a face in a component or group, the normal will need to be transformed. @ip1.pick view, x, y if( @ip1.valid? ) ... other code... ## Detect if pick point is on a face, and if so, orient long axis normal to it # unless axis is locked if @ip.face f = @ip.face puts "Face picked; normal is \n" ####### n = @ip.face.normal; t = @ip.transformation; n.transform! t ####### puts f.normal.inspect; n.inspect if @@axis_lock == NO_LOCK # axis not locked @long_axis = f.normal puts "@long_axis = " + @long_axis.inspect
    • J

      Can a Ruby tool return a value to a 'calling' program?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      5
      0 Votes
      5 Posts
      293 Views
      Dan RathbunD
      @johnwmcc said: Is it possible or allowable to have module-wide variables that aren't global? YES. ALL of your plugins should be within a company or author namespace module. Each of your separate plugins would be within a sub-module of that toplevel module. Let us say for example your toplevel module is named McC and within that you define a @@last_point variable. You can also define getter and setter methods to set and access that variable within the toplevel module: module McC def McC;;last_point @@last_point end def McC;;;astPoint=(pt) @@last_point = pt.is_a?(Geom;;Point3d) ? pt ; Geom;;Point3d.new(0,0,0) end end # module McC OR you could define your shared functionality within a mixin module, and then include it within any of your sub-modules or classes, with which you want to share it with. See the the "Pick-Axe" book on Programming Ruby. It's in the Ruby Resources thread. AND also online in HTML format.
    • J

      Why does this code break?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      9
      0 Votes
      9 Posts
      480 Views
      J
      The advantage of code tags is they can easily be copied and pasted in a code editor, or one of the SketchUp console dialogs. I have my editor and SketchUp set up[1] where I can run the pasted code in SketchUp with the push of a key. So testing posted code is fast and easy - copy, paste, run. That's why it's important to post "run-able" code - leaving variables and constants undefined makes it harder to help. [1] https://github.com/noelwarr/su-tunnel
    • J

      Scaffolding fittings

      Watching Ignoring Scheduled Pinned Locked Moved SketchUp Components, Materials & Styles sketchup
      10
      0 Votes
      10 Posts
      4k Views
      G
      Thank you for sharing! Regards
    • J

      [Plugin] 3D Parametric Shapes - makes placeable components

      Watching Ignoring Scheduled Pinned Locked Moved Plugins
      76
      0 Votes
      76 Posts
      19k Views
      J
      @einstein said: Great thanks, johnwmcc, for this plugin! Thanks for your appreciate comment. @einstein said: Did you consider designing a toolbar for it? I'm sure for many users it became one of the very basic tools in SU. Having it accessible on top of the screen would be nice Not sure I know how to do that, but will consider it when I have time (probably not for at least weeks) - I have several other higher priority projects on the go at the moment, leaving me little time to update this one.
    • J

      Draw a new component with axes at original pick point?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      14
      0 Votes
      14 Posts
      978 Views
      TIGT
      By 'hand built' I mean 'made manually', i.e. without using any code... that's all... If you make a group that straddles the origin, then its origin [axes] are located at its bounds.min... As I tried to explain... you can then move that group from its insertion_point back to the model ORIGIN, and then apply the same translation transformation BUT as an 'inverse', to the group's entities... so that it appears in the same place in the model, BUT its actual axes have been relocated to the ORIGIN...
    • J

      Using View.draw_polyline in rotated component

      Watching Ignoring Scheduled Pinned Locked Moved Plugins
      4
      0 Votes
      4 Posts
      185 Views
      TIGT
      A Point3d behaves much as an Array and vice versa. You can make a point and adjust it's x/y/z values on the fly just as you can with an Array. So pt=Geom::Point3d.new() or even pt=ORIGIN.clone gives you Geom::Point3d.new(0, 0, 0) then pt.x=123.4 OR pt[0]=123.4 gives you Geom::Point3d.new(123.4, 0, 0) A point or array will take .x ,y and .z; as well as [0], [1] and [2]... This lets you read AND set values... pz=pt.z returns 0.0 and pt.z=1 gives us Geom::Point3d.new(123.4, 0, 1.0) etc... I suspect you are over complicating things... To get the z axis of the current 'container', test if it's the model, and if so use Z_AXIS; if not use the container.transformation.zaxis Let's assume we have an object in a container that is called 'obj' if obj.parent==Sketchup.active_model z_axis=Z_AXIS else#it's a group or component z_axis=obj.parent.instances[0].transformation.zaxis end IF you already know where the 'obj' is - e.g. you've made it inside a 'group' then it's even easier... z_axis=group.transformation.zaxis
    • J

      Using View.draw_text method - a bug?

      Watching Ignoring Scheduled Pinned Locked Moved Plugins
      3
      0 Votes
      3 Posts
      366 Views
      J
      Many thanks. For some non-obvious reason, I didn't even SEE the screen_coords method of the View object. I was looking for an equivalent method or property of the point itself. Gratefully.... John MCC
    • J

      Getting error in Layer Manager v2

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      3
      0 Votes
      3 Posts
      411 Views
      Didier BurD
      Hi, Try to replace the min script in your plugins folder with the attached one. I have found a small glitch that may cause the command "lm_set_current" to bug. No sure if it will solve the problem, but... P.S.: nothing to do with an install on D:/ instead of C:/ layer_manager_extension_v6.rb
    • J

      How do I select the built-in Rotate Tool in a script?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      8
      0 Votes
      8 Posts
      445 Views
      J
      Well, progress of a useful kind. I've worked out from the sketchy API for observers how to define an observer to monitor the 'onComponentInstanceAdded' event, and got it to pop up a messagebox when the user has picked the insertion point after the script generates and inserts the component. Now to add the code to select the Rotate tool, instead of the messagebox (which is where I came in!)
    • J

      Print quirks in Layout

      Watching Ignoring Scheduled Pinned Locked Moved LayOut Discussions layout
      3
      0 Votes
      3 Posts
      2k Views
      aadbuildA
      I am also having trouble with templates not printing correctly, I am missing about an inch from the RHS and half an inch from the top & the print preview is as per the previous message. This happens even when I use a standard templates. Is there some way to fix this? I have tried to adjust margins this makes no difference. I am using a HP 8700 A3/ A4 printer. I wonder if the bug has something to do with layout & HP printers? as it happens on both of my HP printers yet these printers print perfectly in progams other than layout. I have not noticed any other threads so these must be an isolated instances, which also makes me think I am doing something wrong. I would greatly apreciate any advice as I can not use layout until I can over come this problem.
    • J

      Starting the CylTool in the sample linetool.rb script

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      3
      0 Votes
      3 Posts
      894 Views
      J
      Well, it wouldn't have 'been clear in the morning' without your clarification, Jim, but it now is - THANKS. I now see that although the Class CylTool is defined, the function to create the tool is NOT 'def'ined. So my slightly modified code now works to provide Draw menu entries for 'Construction line' and 'Cylinder - on axis' with the addition of just these lines at the end of the linetool.rb script where only the first four lines were originally. These functions provide shortcuts for selecting the new tools def linetool Sketchup.active_model.select_tool LineTool.new end def cyltool Sketchup.active_model.select_tool CylTool.new end Add tools to Draw menu if( not file_loaded?("linetool.rb") ) UI.menu("Draw").add_item("Construction line") { linetool } UI.menu("Draw").add_item("Cylinder - on axis") { cyltool } end file_loaded("linetool.rb") I now just want to add a few refinements, which I can see how to do (following the excellent examples elsewhere in this forum and in the script repositories), to: specify the radius or diameter of the cylinder make the drawn cylinder into a group or component automatically design PNG graphics to indicate which tool is in use, instead of the generic white arrow. Thanks again for such a prompt and helpful response - much appreciated. John McC
    • 1 / 1