Help with parallel lines extension code

Okay, it works as I had predicted for a guideline when the code basically bypasses the find_working_plane_normal() method and instead just searches for a face and tests whether the point associated with the cline is on the plane of the face.

JohnBulter_DrawParallelLines_main.rb (9.5 KB)

JohnBulter_DrawParallelLines_changes.txt (1.6 KB) - markdown text

The file I setup to test the 3 main axis and a rotated face:
JB_parallel_lines_test.skp (55.9 KB)

Changes:

  • Wrapped this within a unique JohnButler namespace module.
  • Added a VERSION constant at "2.0.1"
  • As this is not actually a tool interface, I’ve changed a few things so it is treated as a command, (which is what it is. See below comments on why it is not a tool.)
  • The extension submodule is now: DrawParallelLines
  • The command class is now: ParallelLinesCommand
  • The command menu label is now: "Draw Parallel Lines..." (The ellipses is standard UX that means it opens a dialog interface.)
  • Added a right-click context command item. Basically, when you right-click a single object or primitive in the model it is selected and becomes the context for all commands on the popup menu. So, now you can just right-click an edge or guideline and access the command from the popup context menu. (Time saver on a 28" UHD display like mine.)
  • Change @offset to a class variable @@offset so each instance of the command will use the most recently used value as set by the user. (It was being reset to the default each time the command was used.)
  • Added in the get_face_normal_for_cline() method to search for a face associated with a guideline. (Basically, skips the use of the find_working_plane_normal method.)
  • Added a @model instance variable so that this reference need not be passed around or re-referenced in the command’s methods.
  • The class’ instance methods are now in alpha order excepting the constructor’s initialize().

Why it is not a tool ... ( click to expand )

This is not really a tool interface; it is a command. Meaning, the code is basically sequential and does not act like a tool.

  • It does not use any tool callbacks, does not leverage the VCB (ie, Measurements toolbar) for offset input instead implementing an inputbox.
  • It does not have any tool states and does not stay in the tool and reset after each use like a tool interface should. (i.e., a tool would go back to the select edge or cline state as the initial tool state. A tool would reset when the ESC key is clicked.)
  • It does not set a cursor so it looks weird if the user uses custom system cursor scheme. Instead of the SketchUp select cursor, the system arrow cursor is shown. (I use extra large bright orange system cursor scheme that I drew many years ago. So I know immediately when a Ruby tool does not set the cursor.) This is avoided now that the code does not set the command interface as the active tool.
  • A tool generally uses interactive mouse movements and clicks or drags, often at multiple states (stages) of the task.
4 Likes