Author Topic: How to display an end point  (Read 6658 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
How to display an end point
« on: January 15, 2018, 03:28:49 PM »
I want to know how to display an end point of a line without actually drawing a point entity. I could theoretically draw a point at the end point of a polyline and erase it. However I figure there might be a way to achieve this will grdraw or something.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to display an end point
« Reply #1 on: January 15, 2018, 04:10:27 PM »
You can display a point using grdraw/grvecs, however note that the displayed vector graphics will disappear when the screen is redrawn as the user pans or zooms, therefore, if you proceed with this route, you would need to redraw the vector graphics continuously within a grread loop.

If you did want to go with vector graphics, consider the following function:
Code: [Select]
;; grX  -  Lee Mac
;; p - [lst] WCS point at which to display 'X'
;; s - [int] size of point (in pixels)
;; c - [int] ACI colour of point
;; Returns supplied WCS point.

(defun LM:grx ( p s c / -s r q )
    (setq r (/ (getvar 'viewsize) (cadr (getvar 'screensize)))
          q (trans p 0 3)
         -s (- s)
    )
    (grvecs
        (list c
            (list -s -s) (list s  s) (list -s (1+ -s)) (list (1- s)  s) (list (1+ -s) -s) (list s (1-  s))
            (list -s  s) (list s -s) (list -s (1-  s)) (list (1- s) -s) (list (1+ -s)  s) (list s (1+ -s))
        )
        (list
            (list r  0. 0. (car  q))
            (list 0. r  0. (cadr q))
            (list 0. 0. r  0.)
            (list 0. 0. 0. 1.)
        )
    )
    p
)

Example:
Code: [Select]
(defun c:test ( / ent )
    (if (and (setq ent (car (entsel "\nSelect polyline: ")))
             (= "LWPOLYLINE" (cdr (assoc 0 (entget ent))))
        )
        (LM:grx (trans (cdr (assoc 10 (reverse (entget ent)))) ent 0) 5 2)
    )
    (princ)
)

dubb

  • Swamp Rat
  • Posts: 1105
Re: How to display an end point
« Reply #2 on: January 15, 2018, 04:29:19 PM »
Thanks! Very interesting and seems like I might not use vector because it might be easier for me to entmake a point, then entdel it. You always amaze me as always.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to display an end point
« Reply #3 on: January 15, 2018, 05:53:13 PM »
You're welcome, and thank you for your kind words.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: How to display an end point
« Reply #4 on: January 15, 2018, 05:59:17 PM »
Theres also a Grdraw a point thread. :)
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

lamarn

  • Swamp Rat
  • Posts: 636
Re: How to display an end point
« Reply #5 on: January 16, 2018, 01:57:22 AM »
Is there also a method to display 'beginpoint', in a other format than endpoint(s) ?
Design is something you should do with both hands. My 2d hand , my 3d hand ..

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: How to display an end point
« Reply #6 on: January 16, 2018, 04:03:20 AM »
I wrote this many years ago ...
Code: [Select]
; (ALE_DxfTestGrdrawX ptx ang 0 0 vwsz)
; drwcol = colore simbolo 0 > cancella freccia
; drwmod = /= 0 evidenzia la freccia
; vwsz   = (* (getvar "VIEWSIZE") 0.1)
; xtype  = 1 = X - 2 = BOX
(defun ALE_DxfTestGrdrawX (ptx drwcol drwmod vwsz xtype / pt1 pt2)
  (setq
    pt1 (list (- (car ptx) vwsz) (- (cadr ptx) vwsz))
    pt2 (list (+ (car ptx) vwsz) (+ (cadr ptx) vwsz))
  )
  (cond
    ( (= 1 xtype)
      (grdraw pt1 pt2 drwcol drwmod)
      (grdraw (list (car pt1) (cadr pt2)) (list (car pt2) (cadr pt1)) drwcol drwmod)
    )
    ( (= 2 xtype)
      (grdraw pt1 pt2 drwcol drwmod)
      (grdraw (list (car pt1) (cadr pt2)) (list (car pt2) (cadr pt1)) drwcol drwmod)
      (grdraw pt1 (list (car pt2) (cadr pt1)) drwcol drwmod)
      (grdraw (list (car pt2) (cadr pt1)) pt2 drwcol drwmod)
      (grdraw pt2 (list (car pt1) (cadr pt2)) drwcol drwmod)
      (grdraw (list (car pt1) (cadr pt2)) pt1 drwcol drwmod)
    )
  )
)
Code: [Select]
(defun c:Test (  / vwsz pt1 pt2)
  (setq vwsz (/ (getvar "VIEWSIZE") 100)   pt2 '(0 0 0))
  (while (setq pt1 (getpoint "\nPoint: "))
    (ALE_DxfTestGrdrawX pt2 0 0 vwsz 1)
    (ALE_DxfTestGrdrawX pt2 0 0 (/ vwsz 2) 2)
    (ALE_DxfTestGrdrawX pt1 2 0 vwsz 1);giallo X = inizio linea doppia
    (ALE_DxfTestGrdrawX pt2 3 0 (/ vwsz 2) 2);verde box = incrocio con più di due entità
    (setq pt2 pt1)
  )
  (princ)
)

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to display an end point
« Reply #7 on: January 16, 2018, 01:53:40 PM »
Is there also a method to display 'beginpoint', in a other format than endpoint(s) ?

Code: [Select]
(defun c:test ( / ent enx )
    (if (and (setq ent (car (entsel "\nSelect polyline: ")))
             (= "LWPOLYLINE" (cdr (assoc 0 (setq enx (entget ent)))))
        )
        (progn
            (LM:grx (trans (cdr (assoc 10 enx)) ent 0) 5 3)
            (LM:grx (trans (cdr (assoc 10 (reverse enx))) ent 0) 5 1)
        )
    )
    (princ)
)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: How to display an end point
« Reply #8 on: January 16, 2018, 03:23:12 PM »
... Elevation...

lamarn

  • Swamp Rat
  • Posts: 636
Re: How to display an end point
« Reply #9 on: January 16, 2018, 04:27:56 PM »
Trying to get a B and and a E to THE display for both "LINE" and "LWPOLYLINE" objects
How to get the pnt right? Snaps of code that comes into mind.

Code: [Select]

; using
  ;; Display GrText  -  Lee Mac
  ;; pnt  -  cursor point in UCS
  ;; vec  -  GrText vector list
  ;; col  -  Text Colour (ACI Colour)
  ;; xof  -  x-offset from cursor in pixels
  ;; yof  -  y-offset from cursor in pixels


    (.. (entsel "\nSelect a (poly)line: ")))
     (or
             ..
             (= "LINE" (cdr (assoc 0 (setq enx (entget ent))))))
        )
        (progn    
          ..
            (setq strB "B")
    (LM:DisplayGrText pt1 (LM:GrText strB) 1 2 2 )


Would be a cool trick
« Last Edit: January 16, 2018, 04:51:57 PM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How to display an end point
« Reply #10 on: January 16, 2018, 08:28:23 PM »
Use:
vlax-curve-getStartPoint
vlax-curve-getEndPoint

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ScottMC

  • Newt
  • Posts: 192
Re: How to display an end point
« Reply #11 on: January 16, 2018, 10:05:19 PM »
Hey Lee.. Just changing the [start/end] color of the selected object grips would be awesome. Have you peaked @ CATIA and do they label the 'start/end' points? Interesting software.. makes one think how good it would be if we could get more secure or/and generous and work together it would be great.
« Last Edit: January 18, 2018, 12:52:19 PM by ScottMC »

BIGAL

  • Swamp Rat
  • Posts: 1411
  • 40 + years of using Autocad
Re: How to display an end point
« Reply #12 on: January 18, 2018, 03:13:17 AM »
LIke ronjonp use end & start but pick line etc near end this way can swap end values when displayed as closest as say start.
A man who never made a mistake never made anything

lamarn

  • Swamp Rat
  • Posts: 636
Re: How to display an end point
« Reply #13 on: January 18, 2018, 04:41:50 PM »
That works for the text.
Can't figure out how to get the right B/E for a straight line.
And an Arc.

Code: [Select]


(defun c:test3 (/ ent enx)
  (if
    (and (setq ent (car (entsel "\nSelect a (poly)line: ")))
(cond (
(= "LWPOLYLINE" (cdr (assoc 0 (setq enx (entget ent)))))
(= "LINE" (cdr (assoc 0 (setq enx (entget ent)))))
(= "ARC" (cdr (assoc 0 (setq enx (entget ent)))))
       )
)
    )
     (progn

       (LM:grx (trans (cdr (assoc 10 enx)) ent 0) 5 3)
       (LM:grx (trans (cdr (assoc 10 (reverse enx))) ent 0) 5 1)
       (setq ptB (vlax-curve-getStartPoint ent))
       (setq ptE (vlax-curve-getEndPoint ent))
       (LM:grx ptB 5 3)
       (LM:grx ptE 5 1)
       (LM:DisplayGrText ptB (LM:GrText (strcat "B")) 3 15 -15)
       (LM:DisplayGrText ptE (LM:GrText (strcat "E")) 1 15 -15)

     )
  )
  (princ)
)


« Last Edit: January 18, 2018, 05:13:05 PM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to display an end point
« Reply #14 on: January 18, 2018, 04:43:44 PM »
Hint:
Code: [Select]
(LM:grx ptB 5 3)
Similar for ptE, after both have been defined.