
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
blocks containing 12 attributes.
Ask for new value for watts per meter
pick one of the blocks
read LENGTH attribute and multiply by new value
place new value into WATTS attribute of all similer blocks.
So how to cycle through each block twice in order to first pick up LENGHT then repeat to update WATTS?
I have tried many different methods but none work reliably on multiple blocks its driving me nuts! Please help!
The TAG LENGTH comes after the TAG WATTS which must make it more difficult I guess, or does it? Its going to be a pain if you have to keep re-arranging the order of the TAGS.
;Pick set any tape watts
(defun c:PSWATTS()
(graphscr)
(setq cmd (getvar "cmdecho")
olderr *error*
*error* trap)
(setvar "cmdecho" 0)
(setq twts 7)
(setvar "cmdecho" 0)
(setq ep (entlast))
(prompt"\nSet the Wattage per meter [7]..<")
(princ twts)
(princ ">") ;get new value for watts per meter
(setq ss (ssget "_X" (list (cons 0 "INSERT" )(assoc 2 (entget (car (entsel "\nSelect Fitting: ")))))))
(setq sl (sslength ss)
ct 0
ctr 0)
(princ "\nUpdating all Fittings for new wattage....")
(repeat sl ;step through selection set
(setq e1 (ssname ss ct))
(setq ck 2)
(while (not (equal ck "SEQEND"))
(setq e1 (entnext e1)
e2 (entget e1)
ck (cdr (assoc 0 e2)))
(if (= (cdr (assoc 2 e2)) "LENGTH")
(progn
(setq stlen (cdr (assoc 1 e2))) ;get length of tape polyline stored in fitting attribute TAG called LENGTH then
(setq len (atof stlen)) ;multiply by new wattage per meter
(setq len (/ len 1000))
(setq newwatts (* len twts))
(setq wtstr (rtos newwatts 2 1))
)
)
)
(setq ch 2) ;cycle through selection set again to find TAG WATTS
(while (not (equal ck "SEQEND"))
(setq ck (cdr (assoc 0 e2)))
(if (= (cdr (assoc 2 e2)) "WATTS")
(progn
(setq e2 (subst (cons 1 wtstr)(assoc 1 e2)e2))
(entmod e2)
(entupd e1) ;update TAG WATTS with new value
(setq ctr (+ ctr 1)) ;count number of fittings updated.
)
)
)
(setq ct (+ ct 1))
)
(print ctr)
(princ " Fittings were changed to: ")
(princ twts)
(princ " Watts per meter")
(restore)
)
Solved! Go to Solution.