sketchucation logo sketchucation
    • Login
    1. Home
    2. tjrob
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    T
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 5
    • Posts 11
    • Groups 1

    tjrob

    @tjrob

    10
    Reputation
    1
    Profile views
    11
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    tjrob Unfollow Follow
    registered-users

    Latest posts made by tjrob

    • Why I have to say goodbye

      I started developing a rather large and complex plugin to use SketchUp 8 as a 3-d user interface for designing accelerator systems. The license agreement for SketchUp 8 was acceptable, and most of my users could use the free version.

      SketchUp 2013 has a new and very different license. Because of its prohibition on using SketchUp Make for commercial purposes, all of my potential users (except students) will need to purchase SketchUp Pro. That reduces my potential user base to essentially zero, because my users are not going to spend $600 for this.

      I feel somewhat the victim of a "bait and switch". But I do understand the commercial realities for Trimble. I was rather surprised that such a marvelous program was available for free (which I ascribed to Google's legacy).

      So I have to re-assess how to implement my program. I will probably base it on Open Inventor and C++ (I am expert in the latter, and somewhat experienced in the former). It remains to be seen whether to give it a Ruby API, or to translate my Ruby into C++. Or possibly use Java instead of C++ (at which I am also expert). Fortunately I am using only a small fraction of SketchUp's capabilities.

      Ah well, at least I now have a working prototype with all major features. I would not be nearly as far along had I needed to start with Open Inventor and C++ (which was my original plan before I discovered SketchUp).

      So I have to say goodbye. Good luck to you all.

      posted in Developers' Forum
      T
      tjrob
    • RE: Camera Jumps in orientation

      @chris fullmer said:

      I think you can change the model axes to align how you are wanting. Try this, right click on the model axis and choose "Place". Then, to set the axis how you are looking to do, click 1st on the model origin, click 2nd on the negative red axis, click 3rd upwards on the blue axis. That should now realign the axis so that red is to the left, green is up and blue is straight ahead.

      That is funky to use, but it seems to just re-color the axes. The system did not rotate, which it would do if the (new) blue axis was still the z axis.

      I made a lucky guess, and found that on my Mac, pushing Option while dragging with the middle mouse button avoids the jumping and rotates smoothly from the current orientation of the axes. I don't know if pushing Alt does this on Windows.

      Is there any way I can "push" the option key for my user?

      posted in Developers' Forum
      T
      tjrob
    • Camera Jumps in orientation

      In my application, it is traditional for the y axis to be up, with the z axis horizontal along the centerline of a long particle accelerator; x is horizontal to the beam left. I would like to display the world in that orientation; for a side view (looking from the -x axis toward the origin with y up and z to the right): Sketchup.active_model.active_view.camera.set([-1,0,0],[0,0,0],[0,1,0]) Sketchup.active_model.active_view.zoom_extents

      This works fine. But when I use the middle button of the mouse to rotate the display, it immediately jumps so the z-axis is up, and then continues rotating with the mouse.

      This is ugly and highly annoying. Is there any way to disable this behavior so it rotates smoothly from wherever the camera is located?

      posted in Developers' Forum
      T
      tjrob
    • RE: Strange behavior in derived class

      Thank you all for the discussion and suggestions.

      I had not known about .extend() -- it works well, and does precisely what I wanted to do: distinguish different types of transformations (I use .respond_to? to tell if this instance is normal or special, and then use the function only for special ones). This is sort of "inverted inheritance", which is a very Ruby-ish thing to do ๐Ÿ™‚ .

      posted in Developers' Forum
      T
      tjrob
    • RE: Pick closest point of a polyline

      @tig said:

      Let's start simple...

      Thanks, TIG, for the suggestion. Unfortunately it does not work very well at all, basically because in 3D the mouse represents a ray, not a point. Sketchup generates a point via InputPoint and PickHelper using a heuristic that does not work very well at all in this application.

      I have a method that works well:

      • get the mouse ray via view.pickray(x,y)

      • loop over all segments of the polyline

      • compute the position along the line containing the segment, where the ray is closest to the line

      • trim that to the endpoints of the segment

      • compute distance from the resulting point to the ray

      • remember the closest one

      • now I have the segment and location within the segment of the mouse

      • generate the Geom::Transform for that location
        Basically this represents the centerline of a particle accelerator, and the code is inside my custom DragTool, using the mouse to place an object along the centerline; so the object is constrained to lie on the centerline, and its local z-axis is aligned with the centerline where it is located. For <= 200 segments this tracks the mouse quite well; for 1000 segments it takes about 1 second to catch up. That's acceptable for now; ultimately I may optimize it. I'm rather surprised that this much Ruby computation is acceptable.

      If a segment is parallel to the pickray, the math will divide by zero. So my code disallows any segment that is nearly parallel to the pickray. This makes sense, as the user cannot possibly select a position along such a segment; use the middle button to rotate the display so the desired position is visible.

      I ended the centerline with a half-infinite straight line. SketchUp cannot draw that (or rather, it tries to do so, zooming out so much that it's useless). So I split the final segment in two, with the first being half as long as the preceding centerline; the code does not display the final segment.

      The next challenge is to generalize this to include segments that are circular arcs (so far the code is limited to radius=0)....

      If anyone wants my code, or references to the geometrical calculations I'm using, just ask.

      posted in Developers' Forum
      T
      tjrob
    • Pick closest point of a polyline

      I have a polyline with arbitrary 3-d structure, drawn as a series of cline-s. Inside my DragTool.mouse_move I want to determine the closest point on this polyline corresponding to the mouse position. Yes, this is in general ambiguous, but I don't care, and any solution will do. Indeed, as long as it is "close", the user will deal with it by moving the mouse closer to the polyline to remove the ambiguity. Basically I am placing a ComponentInstance along the polyline, moving it as the user moves the mouse, but it's always constrained to line on the polyline (oriented, too, but that's not the issue, and once I have the segment and point of the polyline I'll also have the orientation).

      Any suggestion how to do this?

      posted in Developers' Forum
      T
      tjrob
    • Strange behavior in derived class

      Here is a set of commands in the SU Ruby console:
      ` > class A; end; puts A.new.class
      A
      nil

      class B <A; end; puts B.new.class
      B
      nil
      class C <Geom::Transformation; end; puts C.new.class
      Geom::Transformation
      nil

      (Ignore the "nil"s -- they are unused return values.)`

      How is it that C.new does not return an object with class C?
      How/why does a class derived from Geom::Transform lose its identity?
      How can I fix this -- I have a special coordinate system in my plugin and need to distinguish transformations using it from transformations using the standard coordinates.

      Note that Transformations are complicated enough that I don't want to implement them myself; I would surely get something wrong. I suppose I could make my transformation class have an instance of Geom::Transformation as a class object, but that means I need to implement a large number of functions that just pass through to that object....

      posted in Developers' Forum
      T
      tjrob
    • RE: Calculations on its own thread

      Everything I have tried in attempting to use Thread in SketchUp has failed miserably.

      This works for me:
      timer = UI.start_timer(1.0,true) { start = Time now loop do break if Time.now-start > 0.8 ... long computation involving many loops ... end } ... call stop_timer(timer) when appropriate, perhaps from within the loop
      My computation is copying a file to a WebDialog; the file is output from another process, and can grow over time to be quite large. This code updates the WebDialog once per second, and permits the "Kill" button (in another WebDialog) to work. Each loop reads 1024 bytes from the file and uses WebDialog#execute_script to append it to a textarea (escape \n and " to keep the JavaScript valid); it handles multiple reads at EOF as the file can grow.

      posted in Developers' Forum
      T
      tjrob
    • RE: Query: Edge transparency

      @thomthom said:

      If the track is created as a curve ( entities.add_curve) the native Selection tool will select the whole track even though you click on only one segment of it.

      Great! I had not thought of that. Thanks!

      I have it working with an array of Edge-s. I have since realized that I want to display track information related to where the user clicked on it (i.e. which Edge is clicked -- yes, the physics properties of a track vary along its length). I don't think I can do that with a Curve, as all its Edges get selected with one click.

      posted in Developers' Forum
      T
      tjrob
    • RE: Query: Edge transparency

      Those are both good ideas, and have taught me things I did not know about the SketchUp API. THANKS!

      I have realized that I need to be able to select individual tracks with the mouse, so they must be Entities. Of course one selects only a single Edge of a multi-Edge track, but I can deal with that in a SelectionObserver. When any one of a track's Edge-s is selected, the code will select all of its Edge-s, and display information about the track (in a WebDialog). It already does something similar when a solid object is selected. Putting each track into its own group would let SketchUp select them all, but it looks ugly (the bounding box makes no sense for a track).

      I have made the transparency slider hide the entire Solids layer when its value is less than 2%. Works great! That will also help in selecting tracks when they are inside a solid object.

      Performance is good even with hundreds of solids controlled by the transparency slider -- SketchUp and Ruby are amazing!

      posted in Developers' Forum
      T
      tjrob