Author Topic: How to find vertex number  (Read 9224 times)

0 Members and 1 Guest are viewing this topic.

matrix2005in

  • Guest
Re: How to find vertex number
« Reply #15 on: June 06, 2006, 01:30:25 PM »
CAB
you are right sorry for the confusion...actually i was looking segment number of selected polyline...
it is my mistake...

do you have any idea how to label polyline vertex by??

!) xy coordinates
2) z elevation

thanks
mathew

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: HOw to find vertex number
« Reply #16 on: June 06, 2006, 11:30:55 PM »
Here is a quick and easy way to approach your request.
This should give you some ideas you can work with.
Code: [Select]
(defun c:test ()
  (vl-load-com)
  ;;  no error checking

  (prompt "\nDraw your pline.")
  (command "PLINE")
  (while (> (getvar "CMDACTIVE") 0)
     (command pause)
  )
  (setq ent (entlast))

  (setq ArrowLength 5
        ArrowWidth  2
        )
  (setq ArrowBasePt (vlax-curve-getPointAtDist ent ArrowLength))
  (command "_pedit" ent "_e" "_i" "_non" ArrowBasePt "_x" "_e" "_w" "0" ArrowWidth "_x" "" "")

  (princ)
)

Dear CAB, you do teach me the pedit command in new way
I dont know how to insert an vertex and dont know how to change the segment in different width in pedit before. I think it should be done by subroutine.

Thank you very much, it seems that I should back to learn the acad command.
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to find vertex number
« Reply #17 on: June 07, 2006, 01:11:58 AM »
CAB
you are right sorry for the confusion...actually i was looking segment number of selected polyline...
it is my mistake...

do you have any idea how to label polyline vertex by??

!) xy coordinates
2) z elevation

thanks
mathew
Hi mathew, here is a lisp to label the Z at the coordinate. I leave it to you to modify it to include the XY. I even added a comment where you can get the data to use.
Code: [Select]
(defun c:lblvtx (/ ent i idx pt ss totparam rot)
  (vl-load-com)
  (if (setq ss (ssget '((0 . "*POLY*"))))
    (progn
      (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
      (setq idx -1
    rot (getangle "\nText rotation angle: "))
      (if (not rot)(setq rot 0))
      (while (< (setq idx (1+ idx))(sslength ss))
(setq ent (ssname ss idx))
(setq totparam (fix (vlax-curve-getendparam ent))
      i -1)
(while (< (setq i (1+ i)) totparam)
  (setq pt (vlax-curve-getpointatparam ent i))
  (entmake (list '(0 . "TEXT")
(cons 10 pt)
(cons 7 (getvar "textstyle"))
(cons 40 (getvar "textsize"))
(cons 50 rot)
(cons 1 (rtos (caddr pt) 2 2));;this labels the Z
;;(car pt) is the X, (cadr pt) is the Y
)
   )
  )
)
      (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
      )
    )
  (princ)
  )

matrix2005in

  • Guest
Re: How to find vertex number
« Reply #18 on: June 07, 2006, 10:19:04 AM »
HI jeff

Thank you verymuch for your code...

i am just a begin er of lisp..i edited your code..not sure is it a right method but it works.. :-)
Code: [Select]
(defun c:lblvtx (/ ent i idx pt ss totparam rot)
  (vl-load-com)
  (if (setq ss (ssget '((0 . "*POLY*"))))
    (progn
      (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
      (setq idx -1
    rot (getangle "\nText rotation angle: "))
      (if (not rot)(setq rot 0))
      (while (< (setq idx (1+ idx))(sslength ss))
(setq ent (ssname ss idx))
(setq totparam (fix (vlax-curve-getendparam ent))
      i -1)
(while (< (setq i (1+ i)) totparam)
  (setq pt (vlax-curve-getpointatparam ent i))
  (entmake (list '(0 . "TEXT")
(cons 10 pt)
(cons 7 (getvar "textstyle"))
(cons 40 (getvar "textsize"))
(cons 50 rot)
;(cons 1 (rtos (car pt) 2 2))
(cons 1 (strcat "\n(X="(rtos (car pt) 2 2)")"
"(Y="(rtos (cadr pt) 2 2)")"))
;;this labels the Z
;;(car pt) is the X, (cadr pt) is the Y
)
   )
  )
)
      (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
      )
    )
  (princ)
  )



CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to find vertex number
« Reply #19 on: June 07, 2006, 11:52:52 AM »
Good job Mathew.
You are on your way to being a lisper. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

matrix2005in

  • Guest
Re: How to find vertex number
« Reply #20 on: June 07, 2006, 01:59:53 PM »
CAB
thanks man 8-)

one doubt how can i adjust text size in that code??...i mean it taking from textsize variable but if you create new text style with different height it wont change the text size variable...
eg:- before creating textsize-0.2000 (default)
after creating text style-style1 height-3 still textsize variable is same-0.200

what to do?? :oops:

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to find vertex number
« Reply #21 on: June 07, 2006, 03:01:12 PM »
mathew, here's some code you can input to the other (prior to where the text height is needed, such as right after the (progn )
Code: [Select]
(if (= 0.0
       (setq txthgt
      (cdr
(assoc 40
       (entget
(tblobjname "STYLE" (getvar "TEXTSTYLE"))
)
       )
)
     )
       )
  (setq txthgt (getvar "TEXTSIZE"))
  )
then replace (getvar "TEXTSIZE") with txthgt in this line:
Code: [Select]
(cons 40 (getvar "textsize"))

matrix2005in

  • Guest
Re: How to find vertex number
« Reply #22 on: June 07, 2006, 03:15:50 PM »
Hi jeff

Excellent...that's what i want...lovely :-)

Hey howmany years you peoples are working with lisp...i am surprised you people are writing code like essays...

what is the procedure to learn lisp step by step and what all basics  i need to understand...


Bob Wahr

  • Guest
Re: How to find vertex number
« Reply #23 on: June 07, 2006, 04:12:10 PM »
Jeff's one of the older hands around here, he's been doing it for almost three months now.  I think Kerry has been doing it the longest, he started last year some time.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to find vertex number
« Reply #24 on: June 07, 2006, 04:31:15 PM »
Jeff's one of the older hands around here, he's been doing it for almost three months now.  I think Kerry has been doing it the longest, he started last year some time.
:lmao:
Mathew, I started to toy with lisp a looooong time ago but didn't get serious about it until 3 years, or so, ago. And I use sreious quite loosely here. I still toy with it, but my 'toys' just get bigger, badder, leaner, meaner. :lol:

IMHO, the best way to learn is to figure out something(s) that you do repetitively and try to automate that process, reading the help files and these forums for guidance. Try your best to figure out something on your own before posting for help. It's not that you won't find plenty of us willing to help, but more like if you find the answer through trial & error of your own you will retain how it is done far longer than us just doing it for you.....