Jump to content

Route 3d polyline. The beginning and the end of this 3d polyline.


dilan

Recommended Posts

Hey.

In my program, I make the choice of 3d polylines using the function entsel:

(defun get-entsel-no-error (message / ent)
(setvar "errno" 0)
 (while
   (and
     (not (setq ent (entsel (strcat "\n" message)))
     ) ;_ end of not
     (equal 7 (getvar "errno"))
     ) ;_ end of and
    (setvar "errno" 0)
 ) ;_ end of while
 (cond
   ((equal (getvar "errno") 52)
   nil
    )
   (t
    (list (car ent) (trans (cadr ent) 1 0))
   ))
 )

Is it possible to do so after selecting a 3d polyline somehow showed the route of this 3d polyline, where the beginning and where the end. To the user after selecting the 3d polyline, understand where its beginning.

Well, then he made some further actions .... laid down in the program.

Link to comment
Share on other sites

Your asking for a direction you could use a simple block arrow say placed 1/2 way along the pline.

Try this as a start a text V for arrow

 

(defun c:test ( / obj stpt endpt len pt ang )
(setq oldsnap (getvar 'osmode))
(setq angdirold (getvar 'angdir))
(setq aunitsold (getvar 'aunits))
(setq obj (vlax-ename->vla-object (car (entsel "pick object"))))
(setq stpt (vlax-curve-getstartpoint obj))
(setq endpt (vlax-curve-getendpoint obj))
(setq len (/(vla-get-length obj) 2.0))
(setq pt (vlax-curve-getpointatdist obj len))
(setq ang (+(alg-ang obj pt) (/ pi 2)))
(setvar 'osmode 0)
(setvar 'angdir 0)
(setvar 'aunits 3)
(command "text" "J" "mc" pt 2.5 ang "V")
(setvar 'osmode oldsnap)
(setvar 'angdir angdirold)
(setvar 'aunits aunitsold)
)

Edited by BIGAL
Link to comment
Share on other sites

You could also mark the ends with points. You would have to set a visible pdmode, i use 3.

 

The following function would then put a green point on the start and a red one on the end.

 

The function needs to be passed the polyline as an object, and returns a list of the two object names as a list.

 

(defun mark_ends ( obj / s_obj e_obj rtn)
 (setq ms (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
       s_obj (vla-addpoint ms (vlax-3d-point (vlax-curve-getstartpoint obj)))
       e_obj (vla-addpoint ms (vlax-3d-point (vlax-curve-getendpoint obj)))
 )
 (vlax-put-property s_obj 'color 3)
 (vlax-put-property e_obj 'color 1)
 (setq rtn (list s_obj e_obj))      
)

to delete the two points when no longer needed

 

(foreach x_obj lst
 (vla-delete x_obj)
)  

 

 

To invoke

 

 

(setq lst (mark_ends pl_obj))

Link to comment
Share on other sites

Hey.

In my program, I make the choice of 3d polylines using the function entsel:

(defun get-entsel-no-error (message / ent)
...

Is it possible to do so after selecting a 3d polyline somehow showed the route of this 3d polyline, where the beginning and where the end. To the user after selecting the 3d polyline, understand where its beginning.

Well, then he made some further actions .... laid down in the program.

 

hi, suggestion - transient object

example: LM:GRTEXT

 

or my old utility , little tweaks


 (defun pointer:marker	(pt co / vs)
   (grvecs
     (apply 'append
     (mapcar ''((x)
		(list
		 co
		 pt
		 (polar pt (* pi x) (* 50. (setq vs (/ (getvar "viewsize") (cadr (getvar "screensize"))))))
		 )
		)
	     '(0.0 0.5 1.0 1.5)
	     )
     )
     )
   vs
   )
 

(defun [url="http://www.theswamp.org/index.php?topic=12813.225"]hp:pointer[/url] ( pt c en / enx p tp l ip vs a ang sz d ep ) ; v1.2
 
 (setq enx (entget en))
 (while (and (= (setq p (car (setq tp (grread t 13 0)))) 5) (setq l (cadr tp)))
   (redraw)
   (setq vs  ([color="blue"]pointer:marker[/color] pt 6)
  ip  (osnap l "_nea")
  ip  (if ip
	ip
	l
	)
  a   (angle pt ip)
  sz  (* 50. vs)
  ang (* pi 0.25)
  d   (* sz 0.25)
  ep  (polar ip (+ a pi) 0.)
  )
   
   (grvecs
     (apply 'append
     (mapcar ''((x) (list c ep x))
	     (cons (polar ip a sz) (mapcar ''((f)(polar ep (f a ang) d))(list + -)))
	     )
     )
     )
   (if	en
     (entmod (subst (cons 10 (trans (polar pt (angle pt ip) (+ (distance pt ip) 0.2 sz)) 1 0))
	     (assoc 10 enx)
	     enx
	     )
      )
     )
   ) ;_ end of while
 ip
 )


(defun [color="blue"]msg:pointer[/color] (pts c msg / msg:MTEXT p tp l ip vs obj a sz ang d ep)

(defun msg:MTEXT (str pt sz)
 (entmakex (mapcar 'cons
	   '(0 100 100 1 10 40 50 7 8 71 72)
	   (list "MTEXT" "AcDbEntity" "AcDbMText"
		 (strcat "{\\fComplex|b0|i0|c0|p34;" str "}") ;<-- Ref: CAB's Strip_Text.lsp CopyRight© 2005-2007
		 pt sz 0.0 (getvar "textstyle")
		 "msg_Text" 5 5
		 ) 
	   ) 
   ) 
 ) ;_ end of defun


 
(setq obj (vlax-ename->vla-object
     (msg:MTEXT msg '(0. 0. 0.) 1.0 )
     )
      pt (cond ((car pts))((getvar "viewctr"))))
 
(while (and (= (setq p (car (setq tp (grread t 13 0)))) 5) (setq l (cadr tp)))
   (redraw)

 (setq vs  (pointer:marker pt [color="red"]c[/color])
       ip  (osnap l "_nea")
ip  (if	ip
      ip
      l
      ) 
a   (angle pt ip)
sz  (* 100. vs)
ang (* pi 0.25)
d   (* sz 0.25)
ep  (polar ip (+ a pi) 0.) 
) 
 
 (foreach x pts
   (pointer:marker x [color="red"]c[/color]))
 
  (grvecs
    (apply 'append
    (mapcar '(lambda(x) (list c ep x))
	    (cons (polar ip a sz) (mapcar '(lambda(f)(polar ep (f a ang) d))(list + -)))
	    ) 
    ) 
    )

   
 (if obj
   
   (mapcar '(lambda( a b) (vlax-put obj a b ))
    '( "color" "InsertionPoint" "Height" )
     (list c (trans(polar pt (angle pt ip) (+(distance pt ip) 0.5 sz))1 0) (* 15. vs)))

   )
 
   ) ;_ end of while
      
 (if obj (vla-delete obj))
 
 (redraw)
 
 ip
 
 )

 

test with your routine

(defun c:test (/ tx e en )

 (if (and (setq e ([color="blue"]get-entsel-no-error[/color] "\nPick a polyline "))
   (setq en (car e))
   (wcmatch (cdr (assoc 0 (entget en))) "*LINE,ARC")
   )
   (progn (setq tx (entmakex '((0 . "TEXT") (1 . "START POINT") (10 0. 0. 0.) (62 . 3) (40 . 5))))
   ([color="blue"]hp:pointer[/color] (trans (vlax-curve-getstartpoint en) 0 1) 2 tx)
   (if tx
     (entdel tx)
     )
   ([color="blue"]pointer:marker [/color](trans (vlax-curve-getendpoint en) 0 1) 5 )
   )
   (princ "\nOops! Please retry.. ")
   )
 (princ)
 ) ;_ end of defun


Edited by hanhphuc
add LM:GRTEXT link, add code - msg:pointer
Link to comment
Share on other sites

another msg:pointer - updated at post#4

display both points

 

(defun c:test2 (/ en pts )
 (if (and (setq en (get-entsel-no-error "\nPick a polyline "))
   (setq en (car en))
   (wcmatch (cdr (assoc 0 (entget en))) "*LINE,ARC")
   )
   (progn 
   (setq pts (mapcar ''((x) (trans ((eval (read (strcat "vlax-curve-get"x))) en) 0 1) ) '("StartPoint" "EndPoint")))
          ([color="blue"]msg:pointer[/color]  pts [color="red"]AcGreen[/color] [color="purple"]"START POINT"[/color]) [color="green"]; ACI color = 3[/color]
           (mapcar ''((a b) ([color="blue"]pointer:marker[/color] a b)) pts '([color="red"]6 5[/color])) [color="green"]; <-- you can change color index here [/color]
   )
   (princ "\nOops! Please retry.. ")
   )
 (princ)
 ) ;_ end of defun

Edited by hanhphuc
Link to comment
Share on other sites

another msg:pointer - updated at post#4

display both points

 

(defun c:test2 (/ en pts )
 (if (and (setq en (get-entsel-no-error "\nPick a polyline "))
   (setq en (car en))
   (wcmatch (cdr (assoc 0 (entget en))) "*LINE,ARC")
   )
   (progn 
   (setq pts (mapcar ''((x) (trans ((eval (read (strcat "vlax-curve-get"x))) en) 0 1) ) '("StartPoint" "EndPoint")))
          ([color="blue"]msg:pointer[/color]  pts [color="red"]AcGreen[/color] [color="purple"]"START POINT"[/color]) [color="green"]; ACI color = 3[/color]
           (mapcar ''((a b) ([color="blue"]pointer:marker[/color] a b)) pts '([color="red"]6 5[/color])) [color="green"]; <-- you can change color index here [/color]
   )
   (princ "\nOops! Please retry.. ")
   )
 (princ)
 ) ;_ end of defun

Thank you.

Your option suited me. I realized what I wanted.

Link to comment
Share on other sites

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