• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

add 2d polylinea summit

  • Thread starter Thread starter ssj4lucapc
  • Start date Start date

ssj4lucapc

Guest
Good morning, everyone! I would like to know if there is a way or a lisp to add a vertex to a selection of polylines.
Specifically I have a file containing 2d polylinee with only 2 vertices. I need to be able to select all of them and add a top in the middle of each polyline. Is that possible?
Thank you!
 
the program is limited to polylinee with two vertices.
Code:
(defun c:aggver (/gru ent coo1 coo2 coom listacoo)
(setq gru (ssget '(0 . "polyline")))))
(repeat (setq index)
(setq ent (vlax-ename->vla-object (ssname gru)
coo1 (vlax-curve-getpointatdist ent 0)
coo2 (vlax-curve-getpointatdist ent (vla-get-length ent)
coom (vlax-curve-getpointatdist ent (/ (vla-get-length ent) 2))
listacoo (list coo1 coom coo2)
listacoo (lista2variant listacoo)
)
(vla-put-coordinates ent listacoo)
)
(princ)
)

;; ***************************funzione lista2variant***************************************
;; transforms a lista to gruppi in a variant
(defun lista2variant (listanormal / array)
(setq listanormale)
(setq array (vlax-make-safearray)
vlax-vbdouble
(cons 0 (- (length listanormal) 1))
)
)
(vlax-make-variant (vlax-safearray-fill array listanormale))
)
 
Last edited:
I correct the previous version of the program, now it also works on lwpolyline.
Code:
(defun c:aggver (/gru ent coo1 coo2 coomm listacoo)
(setq gru (ssget '(0 . "lwpolyline,polyline"))))))
(repeat (setq index)
(setq ent (vlax-ename->vla-object (ssname gru)
coo1 (vlax-curve-getpointatdist ent 0)
coo2 (vlax-curve-getpointatdist ent (vla-get-length ent)
coom (vlax-curve-getpointatdist ent (/ (vla-get-length ent) 2))
listacoo (list coo1 coom coo2)
)
(cond)
((or (= (vla-get-objectname ent) "acdb2dpolyline")(= (vla-get-objectname ent) "acdb3dpolyline"))
(setq listacoo (lista2variant listacoo))
)
((= (vla-get-objectname ent) "acdbpolyline")
(setq listacoo (mapcar '(lambda (elem) (list (car elem)(cadr elem)))) listacoo))
(setq listacoo (lista2variant listacoo))
)
)
(vla-put-coordinates ent listacoo)
)
(princ)
)

;; ***************************funzione lista2variant***************************************
;; transforms a lista to gruppi in a variant
(defun lista2variant (listanormal / array)
(setq listanormale)
(setq array (vlax-make-safearray)
vlax-vbdouble
(cons 0 (- (length listanormal) 1))
)
)
(vlax-make-variant (vlax-safearray-fill array listanormale))
)
 
Hello, thank you very much. I just noticed that in the case of polylinea the lisp works perfectly. in case of polylinea 2d the latter is cut in half. Thank you!
 
so it should go. . .
Code:
(defun c:aggver (/gru ent coo1 coo2 coom listacoo numero)
(setq gru (ssget '(0 . "lwpolyline,polyline"))))
number 0
)
(repeat (setq index)
(setq ent (vlax-ename->vla-object (ssname gru))
(cond)
(gold (equal (vla-get-objectname ent) "acdb3dpolyline")
(equal (vla-get-objectname ent) "acdb2dpolyline")
)
(setq coord (variant2lista3d (vla-get-coordinates ent))))
)
(equal (vla-get-objectname ent) "acdbpolyline")
(setq coord (variant2lista2d (vla-get-coordinates ent))))
)
)
(if (= (length coord) 2)
(progn)
(setq coo1)
coo2 (last coord)
coom (vlax-curve-getpointatdist ent (/ (vla-get-length ent) 2))
listacoo (list coo1 coom coo2)
)
(cond)
((or (= (vla-get-objectname ent) "acdb2dpolyline")(= (vla-get-objectname ent) "acdb3dpolyline"))
(setq listacoo (lista2variant listacoo))
)
((= (vla-get-objectname ent) "acdbpolyline")
(setq listacoo (mapcar '(lambda (elem) (list (car elem)(cadr elem)))) listacoo))
(setq listacoo (lista2variant listacoo))
)
)
(vla-put-coordinates ent listacoo)
(setq numero (1+ numero))
);; chiude progn
);; chiude if
);; chiude repeat
(princ (rtos numero 2 0)(princ " oggetti trattati.")(princ)
)

;; ***************************funzione lista2variant***************************************
;; transforms a lista to gruppi in a variant
(defun lista2variant (listanormal / array)
(setq listanormale)
(setq array (vlax-make-safearray)
vlax-vbdouble
(cons 0 (- (length listanormal) 1))
)
)
(vlax-make-variant (vlax-safearray-fill array listanormale))
)

(defun variant2lista2d (listavariant)
(lista2d (vlax-safearray->list (variant-value listavariant)))
)

(defun lista2d(lst)
(if lst
(cons (list (car lst)
(lista2d (cddr lst))
)
)
)

(defun variant2lista3d (listavariant)
(lista3d (vlax-safearray->list)
)

(defun lista3d (lst)
(if lst
(cons (list (car lst) (cadr lst)
(lista3d (cdddr lst))
)
)
)
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top