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
Posted (edited)

 

Excuse me

I need to insist on the question.
@dexus: You said you're used to doing this kind of task. Therefore, I assume you can answer this question: does running the code on the polyline shown in the clip work as it should?

 

Edited by GLAVCVS
  • Like 1
Posted

For an accurate snap the drag point needs to be on the polyline, so not an accurate snap.

 

At a certain point it stops following the surrounding shapes, works well on the straight with taper in my drawing.

 

On the Taper at the top keyboard input seems okay, the arc sections not so accurate.

 

It is an interesting LISP though.

Posted
14 hours ago, GLAVCVS said:

 

Excuse me

I need to insist on the question.
@dexus: You said you're used to doing this kind of task. Therefore, I assume you can answer this question: does running the code on the polyline shown in the clip work as it should?

 

 

 

 

For me it works as expected, I mostly use it on arcs that are symmetrical though. Those results seem more logical:

offset.gif.a2ca5ba7f03548bbdf0d213547d900cc.gif

 

But the vertexes stay in line and the lines stay tangent to each other.

I guess increasing the arc size of the arc instead might be another option.

What would be the expected result for you? I'm not sure if you can keep the constraints without changing the position of that gray line in its direction.

 

  • Thanks 1
Posted

Here was my post with my examples...

 

 

I was working towards modifying Lee Macs OffsetSection LISP (mostly trying some of those functions), but getting a proper response from the adjacent sections is tedious.

 

Here is a single offset modifications of it... 

 

 

For my needs as stated earlier, I might need to work on just a redraw from the inputs for the radii, etc.

 

 

Your LISP looks pretty good for moving roads, certainly useful.

 

AFAIK, I don't have any upcoming road projects, though I might need to fine tune a few, they never put them exactly where I draw them.

Posted (edited)

Hi,

Here’s a preview of what the new Offsetea will look like.

Sorry for the delay — I’ve had other things to take care of.

Still, I believe the wait will be worth it.

Each improvement leads to another... but I think I'm going to stop here 😆

I still need to fine-tune a few things, but the final result will be very close to what you see in the clip:

 

-Projection of straight line segments

-3 projection modes for arc segments (one of them is the same as the one Evgeny proposed in his code) + 1 custom mode that I still have to write. Switching between modes is as simple as pressing keys 1, 2, 3, or 4

-Snapping to adjust position with the cursor

-Real-time "texting" using grread in all cases

-Voice assistance to provide useful info

 

 

I'll try to finish it this week, but I can’t promise anything — I’ve got quite a bit of work.

Still, I hope that with this small preview I’ve earned a bit of your patience 🙂

 

 

 

 

 

 

 

Edited by GLAVCVS
  • Like 2
Posted

As time allows, I am still working at this.

 

I have a conveyor screw to completely design and detail this week.

 

I made a few tries messing with @Lee Mac's Offset Section LISP using some of those functions, but, I might try a new route.

  • 1 month later...
Posted (edited)

Hola de nuevo,

 

Dejé una tarea pendiente en este hilo que intentaré cerrar.
Adjunto una nueva versión de Offsetea .
A continuación, explico el comportamiento y las opciones del comando.

Partimos de una lógica de trabajo basada en el enfoque del código de Evgeny Elpanov. De hecho, esta lógica es más fácil de explicar en código que con palabras: proyectar un segmento entre dos vectores guía (definidos por los extremos del segmento y el punto que precede a cada uno de ellos) que se intersecan en un punto, que se convierte en el foco de la proyección.

Al proyectar segmentos rectos, el resultado solo puede ser uno. Sin embargo, en el caso de segmentos de arco, ¿qué ocurre si reemplazamos el foco de proyección?
En base a esto, se me ocurrieron dos opciones adicionales: el centro y el polo del arco. También consideré la posibilidad de añadir una tercera opción que permitiera al usuario especificar la ubicación del foco en pantalla. Sinceramente, no creo que esto sea útil (espero que al menos una de las otras dos lo sea 😅).

Así, la funcionalidad del comando es la siguiente:

- Selección del segmento de polilínea a proyectar: el comando solo funcionará si la polilínea está compuesta por 2 o más segmentos.

Si el segmento seleccionado es recto , los vectores guía se definirán por sus extremos y el punto anterior de cada uno (es decir, los segmentos adyacentes). Si uno de los extremos del segmento es también un extremo de la polilínea, el vector guía para ese extremo será la normal a él.

Si el segmento es un arco , los vectores guía predeterminados serán los mismos que para los segmentos rectos (propuesta de Evgeny). Sin embargo, aquí es posible cambiar el enfoque del enfoque secante de Evgeny (tecla '2') al enfoque radial (tecla '1') o al enfoque tangente (tecla '3').


En cuanto a las herramientas de control del segmento a proyectar, he implementado un ajuste al estilo GLAVCVS , limitado a los casos posibles para este comando: _end, _mid, _int, _cen, _nod, _ins, _nea.
Este ajuste se puede activar o desactivar con F3.

 

La relación entre la posición del cursor y el segmento a proyectar siempre será de seguimiento de segmento en los segmentos rectos. Sin embargo, en los segmentos de arco, puede ser de seguimiento de arco o de cuerda.
Para alternar entre ambos, simplemente pulse TAB.


El seguimiento de arco está activo mientras el cursor permanece entre los dos vectores de proyección. De lo contrario, cambia automáticamente al seguimiento de cuerda. La diferencia entre ambos radica, por lo tanto, en el comportamiento cuando el cursor se encuentra entre los vectores guía.
Estos vectores guía se muestran en pantalla como dos líneas discontinuas rojas.

Junto al cursor se muestra texto informativo en tiempo real:

Para segmentos rectos (de arriba a abajo): la distancia de desplazamiento desde la ubicación inicial y la longitud del segmento.

Para segmentos de arco: distancia de desplazamiento desde la ubicación inicial, radio del arco, longitud del arco y longitud de la cuerda. La visibilidad de esta información se puede activar o desactivar con la tecla "i" .


Por último, puedes aumentar o disminuir el tamaño de los indicadores junto al cursor presionando las teclas '+' o '-'.

 

En cuanto al rendimiento del comando, mientras escribía el código, descubrí una mayor variedad de casos de los que inicialmente había pensado. Si el objetivo principal era lograr el seguimiento del segmento de arco según la posición del cursor, creo que este código cubrirá aproximadamente el 90 % de los casos posibles. 

En los casos donde no sea posible el seguimiento del arco, se realizará a nivel de la cuerda.

 

Espero que a alguien le resulte útil.

 

Offsetea_v2.lsp

Edited by GLAVCVS
  • Like 1
Posted

P.S.:

The interface is available in both Spanish and English. If your operating system language is different, the voice messages will be read in English, but with the pronunciation of your language.
If this is your situation and it bothers you, you should search the code for all the English phrases and translate them into your language. It shouldn't take you more than half an hour.
You can also mute the speakers 🙃.

Everyone can do what they think is best.

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...