Code Red > AutoLISP (Vanilla / Visual)

Increase number of attribute block along a polyline

(1/3) > >>

PM:
Hi, I am using this code to increase number of attribute block along a polyline. Some times I have situations like the example in the *.dwg file that I want to keep some numbers and increase number only to blocks without number.

The change i want to do is to choose pick the first emply point and then give the start number for example 20 and add 21,22,23.....etc only to blocks without number on the selected polyline. Is any way to do this?


--- Code - Auto/Visual Lisp: ---(defun c:pblinclw ( / ListClockwise-p osm ss lw vl pt n pr k v bl att )   (defun ListClockwise-p ( lst / z vlst )    (vl-catch-all-apply 'minusp       (list        (if           (not             (equal 0.0              (setq z                (apply '+                  (mapcar                     (function                      (lambda (u v)                        (- (* (car  u) (cadr  v)) (* (car  v) (cadr  u)))                      )                    )                    (setq vlst                      (mapcar                        (function                          (lambda (a b) (mapcar '- b a))                        )                        (mapcar (function (lambda (x) (car lst))) lst)                         (cdr (reverse (cons (car lst) (reverse lst))))                      )                    )                    (cdr (reverse (cons (car vlst) (reverse vlst))))                  )                )              ) 1e-6            )          )          z          (progn            (prompt "\nChecked vectors are colinear - unable to determine clockwise-p of list")            nil          )        )      )    )  )   (setq osm (getvar 'osmode))  (setvar 'osmode 8)  (prompt "\nPick 2D LWPOLYLINE that has blocks with attributes to increment at its vertices...")  (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))  (setq lw (ssname ss 0))  (setq vl (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget lw))))  (if (not (ListClockwise-p vl)) (setq vl (reverse vl)))  (setq pt (getpoint "\nPick starting point : "))  (setq n (length vl))  (setq pr (getstring "\nSpecify prefix : : "))  (setq vl (vl-member-if '(lambda (x) (equal (list (car pt) (cadr pt)) x 1e-6)) (reverse (cdr (vl-member-if '(lambda (x) (equal (list (car pt) (cadr pt)) x 1e-6)) (reverse (append vl vl)))))))  ;(setq k 0)  (initget 6)    (setq k (1- (cond ( (getint (strcat "\nSpecify start number <" (itoa 1) "> : "))) ( 1 ))))  (repeat n    (setq k (1+ k))    (setq v (car vl))   (setq bl  (ssname    (ssget      "_X"      (list        '(0 . "INSERT")         '(66 . 1)         '(-4 . "<,<,*")        (list 10 (+ (car v) 1e-6) (+ (cadr v) 1e-6) 0.0)        '(-4 . ">,>,*")        (list 10 (- (car v) 1e-6) (- (cadr v) 1e-6) 0.0)      )    )    0  ))    (setq att (entnext bl))    (entmod (subst (cons 1 (strcat pr (itoa k))) (assoc 1 (entget att)) (entget att)))    (entupd att)    (setq vl (cdr vl))  )  (setvar 'osmode osm)  (princ)) 

Thanks

PM:
Is it possible to be done ?

Thanks

PM:
Something like this, Is it possible to be done ?

Thanks

mhupp:
getpropertyvalue & setpropertyvalue don't work with my version of BricsCAD so can't test this. But this should get you moving in the right direction.


--- Code - Auto/Visual Lisp: ---(defun C:PTXT (/ i ss tag)   (vl-load-com)  (setq i (getint "\nStarting Number: "))  (if (setq ss (ssget '((0 . "INSERT") (66 . 1))))    (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))      (if (and (setq tag (getpropertyvalue blk "POINT")) (eq "" tag))       ;if block has point attribuet and its blank        (progn          (setpropertyvalue blk "POINT" (rtos i 2 0))          (setq i (1+ i))        )        (princ "\"LINE NO\" Attribute not found.")       )    )  )  (princ))

PM:
Hi mhupp . Thanks for the replay. Is not possible to select the polyline, and pick the first point and search clockwise to find the empty number point and increase the number by the giving start number ?

Because with your code I have to select the points with one by one to have the correct numbers at the end. That's why I post the code to modify .

Thanks

Navigation

[0] Message Index

[#] Next page

Go to full version