Jump to content

Recommended Posts

Posted

I'll see what this week brings for extra playtime.

Posted (edited)

I managed to get rid of the flickering but keeping snap enabled.

Here is the new version:

offset.lsp

 

Instead of hiding the polyline before doing the osnap, I now keep the polyline hidden and render it with grvecs instead. Therefore no snapping to itself and no more flickering! 😆

Edited by dexus
  • Like 4
Posted (edited)

@dexus Well done! This works very well!

 

Just a suggestion if you wish to add more to it. My code below is for incorporating Function keys during a grread loop would be a good addition. It doesn't support everything, like Snap, polar tracking, osnap tracking, but it does all the toggle modes. It can replace the return condition in your grread loop.

;|==============================================================================
  Function Name: (pjk-Grread-Fkeys <Character Code))
  Arguments:
             kcode = integer; The Character code from the second element in the return from GRREAD.
  Returns:
             T if ENTER or SPACEBAR is pressed, otherwise NIL
  Description:
     This function emulates the functions performed when a function key is selected
     within a GRREAD loop.

     Created by Phil Kenewell 2018
================================================================================|;
(defun pjk-Grread-Fkeys (kcode / acv ret)
   (setq acv (atof (substr (getvar "acadver") 1 4)))
   (cond
      ((= kcode 6) ;; F3
         ;; Faster more efficient way to toggle osmode. Thanks to Lee Mac for the idea.
         (princ
            (strcat "\n<Osnap "
               (if (>= (setvar "osmode" (boole 6 (getvar "osmode") 16384)) 16384) "off>" "on>")
            )
         )
      )
      ((= kcode 25) ;; F4
         (if (>= acv 18.1) ;; If AutoCAD 2011 or Higher
            (princ
               (strcat "\n<3DOsnap "
                 (if (= (logand (setvar "3dosmode" (boole 6 (getvar "3dosmode") 1)) 1) 1) "off>" "on>")
               )
            )
            (princ
               (strcat "\n<Tablet " 
                  (if (= (setvar "tabmode" (- 1 (getvar "tabmode"))) 1) "on>" "off>")
               )
            )
         )
      )
      ((= kcode 5) ;; F5
         (cond
           ((= (getvar "SNAPISOPAIR") 0)(setvar "SNAPISOPAIR" 1)(princ "\n<Isoplane Top>"))
           ((= (getvar "SNAPISOPAIR") 1)(setvar "SNAPISOPAIR" 2)(princ "\n<Isoplane Right>"))
           ((= (getvar "SNAPISOPAIR") 2)(setvar "SNAPISOPAIR" 0)(princ "\n<Isoplane Left>"))
         )
      )
      ((= kcode 4) ;; F6
         (if (>= acv 17.0) ;; If AutoCAD 2007 or Higher
            (princ
               (strcat "\n<Dynamic UCS "
                  (if (= (setvar "ucsdetect" (- 1 (getvar "ucsdetect"))) 1) "on>" "off>")
               )
            )
            (princ
               (strcat "\n<Coords "
                  (if (= (setvar "coords" (if (= (getvar "coords") 2) 0 2)) 2) "on>" "off>")
               )
            )
         )
      )
      ((= kcode 7) ;; F7
         (princ
            (strcat "\n<Grid "
               (if (= (setvar "gridmode" (- 1 (getvar "gridmode"))) 1) "on>" "off>")
            )
         )
      )
      ((= kcode 15) ;; F8
         (princ
            (strcat "\n<Ortho "
               (if (= (setvar "orthomode" (- 1 (getvar "orthomode"))) 1) "on>" "off>")
            )
         )
      )
      ((= kcode 2) ;; F9
         (princ
            (strcat "\n<Snap "
               (if (= (setvar "snapmode" (- 1 (getvar "snapmode"))) 1) "on>" "off>")
            )
         )
      )
      ((= kcode 21)  ;; F10
         (princ
            (strcat "\n<Polar "
               (if (= (logand (setvar "autosnap" (boole 6 (getvar "autosnap") 8)) 8) 8) "on>" "off>")
            )
         )
         (Princ "\nNOTE: Polar Tracking is not supported in this command.")
      )
      ((= kcode 151) ;; F11
         (princ
            (strcat "\n<Object Snap Tracking "
               (if (= (logand (setvar "autosnap" (boole 6 (getvar "autosnap") 16)) 16) 16) "on>" "off>")
            )
         )
         (Princ "\nNOTE: Object Snap Tracking is not supported in this command.")
      )
      ((= kcode 31) ;; F12
         (if (>= acv 16.2) ;; If AutoCAD 2006 or Higher
            (princ
               (strcat "\n<Dynamic Input "
                  (if (minusp (setvar "dynmode" (- (getvar "dynmode")))) "off>" "on>")
               )
            )
         )
      )
      ((vl-position kcode '(13 32)) ;; Enter or Spacebar
         (setq ret T)
      )
   )
   ret
) ;; End Function (pjk-Grread-Fkeys)

 

Edited by pkenewell
  • Like 2
Posted
5 hours ago, dexus said:

I managed to get rid of the flickering but keeping snap enabled.

Here is the new version:

offset.lsp 10.87 kB · 1 download

 

Instead of hiding the polyline before doing the osnap, I now keep the polyline hidden and render it with grvecs instead. Therefore no snapping to itself and no more flickering! 😆

This is much better.

 

After seeing your code, I think there's something I may have misunderstood or didn't consider important: the use of the chord as a control parameter. All along, I've been thinking that the main goal was to ensure the cursor was tangent to the curve at all times. But I see that using the chord is important.

Clearly, these types of tasks were never part of my CAD menu.
In any case, this forces me to change my approach somewhat: I'll try to make 'offsetea' versatile in this case.

  • Like 1
Posted

Another necessary question: Does the original code work as expected when selecting an arc segment flanked by other arc segments?
Is it possible this isn't intended in the code?

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...