@rolisonfelipe wrote:
…. ;I found a better lsp to be edited, and add some elements that wanted, but it is limited to polylines ….
You have a solution, but I'd simplify and shorten and update it as below [lightly tested]. That routine has some inefficiencies, problems, etc.:
Would you ever type out the whole command name "VERTEX," when you can use "VV" (and the code tells you to)? I just defined the name as VV directly. [But if it were up to me, I'd name it differently -- VV doesn't seem to be "about" what it does.]
It uses an old-fashioned way of setting up error handling, and defines *error* outside the command, and does not restore the original unless there is an error -- without one, this routine's *error* handler will be imposed on AutoCAD operations in general, and if it is triggered by something unrelated, it will encounter a variable that doesn't exist! And if there's an error within running it, in Acad2015 and beyond you'll be scolded for using (command) in the *error* handler [for the Undo End part].
There's no need to specify Continuous linetype -- that is always the default for new Layers; and non-continuous linetypes are not applicable to Points, anyway, so the linetype doesn't matter.
It does not return the current Layer to what it was.
You can use (vlax-curve...) functions and Parameters to process LW Polylines the same way as "heavy" ones, so there's no need for separate sub-routines [which also removes a lot of variables].
It can limit the object types it will "see" in selection, rather than let you select just anything, and then go through and check each one's entity type.
I can't figure out why it's checking one coordinate only of the extrusion direction. If that was about handling them in different UCS's, mine does that in a different and much simpler way.
Variables that are used only once have been eliminated, and whatever was setting them used directly. I kept variable names that are still there as they were, and most prompts, but prompts I added or changed are in English, so you'll want to translate them. [And I changed SGPOLY to SGPLA for Polyline/Line/Arc.]
(defun C:VV
(/ *error* doc svnames svvals SGPLA NUMOBJ NAMENT ENTGT TIPENT)
;;;
(defun *error* (errmsg)
(princ (strcat "\n»» Aplicação interrompida com erro: " errmsg))
(mapcar 'setvar svnames svvals); reset System Variables
(vla-endundomark doc)
(princ)
); defun - *error*
;;;
(vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object))))
(setq ; System Variable saving/resetting without separate variables for each:
svnames '(osmode cmdecho clayer); System Variable names
svvals (mapcar 'getvar svnames); starting System Variable values
); setq
(mapcar 'setvar svnames '(0 0)); Osnap & command echoing off
(command "_.layer" "_thaw" "POINT" "_make" "POINT" "c" "1" "" "")
(setvar 'pdmode 35); <--EDIT for preferred Point display style
(prompt "\nTo draw Points at Polyline/Line/Arc vertices & endpoints,")
(while (not (setq SGPLA (ssget '((0 . "*POLYLINE,LINE,ARC")))))
(prompt "\n»» Nenhuma Polyline/Line/Arc entidade seleccionada!\n")
); while
(repeat (setq NUMOBJ (sslength SGPLA))
(setq
NAMENT (ssname SGPLA (setq NUMOBJ (1- NUMOBJ)))
TIPENT (cdr (assoc 0 (entget NAMENT)))
); setq
(if (wcmatch TIPENT "*POLYLINE")
(repeat ; then
(setq n
(+ (fix (vlax-curve-getEndParam NAMENT)) (if (vlax-curve-isClosed NAMENT) 0 1))
); setq
(command "_.point" (trans (vlax-curve-getPointAtParam NAMENT (setq n (1- n))) 0 1))
); repeat
(command ; else [Line or Arc]
"_.point" (trans (vlax-curve-getStartPoint NAMENT) 0 1)
"_.point" (trans (vlax-curve-getEndPoint NAMENT) 0 1)
); command
); if
); repeat
;;;
(mapcar 'setvar svnames svvals); reset System Variables
(vla-endundomark doc)
(princ)
); defun -- C:VV
(princ "\n»» start VV \n")
Kent Cooper, AIA