Message 1 of 14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
(defun c:bka (/ ss len i sum blk blkref atts attval)
(setq ss (ssget)
len (sslength ss)
i 0
sumsv 0
sumcd 0
list1 ()
list2 ()
)
(repeat len
(progn
(setq blk (ssname ss i)
blkref1 (entnext blk)
dxf1 (entget blkref1)
blkref2 (entnext blkref1)
dxf2 (entget blkref2)
)
(cond
((eq
(strcase (cdr (assoc 2 dxf1)) 1)
"so_vach"
)
(progn
(setq sv (- (atof (cdr (assoc 1 dxf1))) 0.5)
sumsv (+ sumsv sv)
cd (atof (cdr (assoc 1 dxf2)))
)
(if (assoc cd list1)
(progn
(setq temp (+ sv (cdr (assoc cd list1))))
(subst (cons cd temp) (assoc cd list1) list1)
)
(setq list1 (cons (cons cd sv) list1))
)
)
)
((eq
(strcase (cdr (assoc 2 dxf1)) 1)
"chieu_dai"
)
(progn
(setq attval (atof (cdr (assoc 1 dxf1)))
sumcd (+ sumcd attval)
)
)
)
)
(setq i (1+ i))
)
)
(princ (strcat "\n" "so vach 7.3: " (rtos sumsv)))
(foreach ele list1
(princ (strcat "\n" (rtos (cdr ele)) " vach " (rtos (car ele)) "(m)"))
)
(princ (strcat "\n" "tong cd vach 7.1: " (rtos sumcd 2 1)))
(princ)
)
I am making lisp that count and display block's attributes. As showing in video, while the total number of road markings showing by lisp is just fine, the number of marks of each length is showing wrong. Calculated seem to stuck with the 1st encounterd value of each length type that it approaching
I am making lisp that count and display block's attributes. As showing in video, while the total number of road markings showing by lisp is just fine, the number of marks of each length is showing wrong. Calculated seem to stuck with the 1st encounterd value of each length type that it approaching
Solved! Go to Solution.