Namaste,
Can anyone please help me out with a lisp / command which identifies the bar diameter and changes the layer & color of the bars it is indicating (nearest to arrow pointer)
For ex: 8mm green, 10mm blue, 12mm orange 16mm magenta, 20mm red, 25mm flourecent green.
Thank you for your valuable time.
Best regards,
PNP
PS: i am using another lisp to give the length of the each bar dia and multiply them manually by 2 (usually we will have 2 bars in a beam ) to get the overall length for boq purposes.
Solved! Go to Solution.
Solved by ec-cad. Go to Solution.
Solved by ec-cad. Go to Solution.
Post a dwg how do you determine what is a 8mm bar ? Why not draw bars on layers 8mm, 10mm etc. You can make a choose dia pretty quick say a lisp defun if you type 8 it will set layer 8mm.
(defun c:8 ()(setvar 'clayer "8mm"))
(defun c:10 ()(setvar 'clayer "10mm"))
(defun c:12 ()(setvar 'clayer "12mm"))
Namaste,
Thanks a lot for your quick response @Sea-Haven. PFA typical drawing we prepare. We indicate the bars and no. of bars as attributes. Drawing the bars of 8, 10 etc. in layers is time consuming and also is prone to change by designer leading to rework. I am new to VBA coding. So, do not know how the below code works. Request you to please help
Best regards,
prash1730
You should probably rename the 2nd Attribute Tagname in your block 'NO' so it is unique. Perhaps name it as "DIM".
This Lisp will get you started. Once you get the Diameters, you can do the Color change..
;; Get_Bars.lsp
(vl-load-com)
(setq ss nil)
(setq ss (ssget "X" (list (cons 2 "NO")(cons 0 "INSERT"))))
(if ss
(progn
(setq C 0)
(repeat (sslength ss)
(setq blk (vlax-ename->vla-object (ssname ss C)))
(if (safearray-value (setq atts (vlax-variant-value (vla-getattributes blk))))
(progn
(setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))))
(setq ctr 0 Dia "")
(foreach att atts
(setq Tag (vla-get-tagstring att))
(if (= Tag "00")
(setq ctr (+ ctr 1))
); if
(if (= ctr 2); second attribute with tagname "00"
(setq Dia (vla-get-textstring att))
); if
); foreach
); progn
); if
(if (/= Dia "")
(princ (strcat "\nFound Diameter of: " Dia))
); if
(setq C (+ C 1))
); repeat
); progn
); if
(princ)
Hmm..
Looks like I missed the question. You want to change the Color and Layer of the 'lines' that the NO block / Leader are pointing at ? They are not 'attached' in any manner that I can determine. Maybe you could 'pick' the NO block, extract the value, say 12. Then pick the lines that you want to change ?
Prash1730
I'm working on it have a lisp for you to check out.
Next phase would be to get the Lines, and change the Color per your specs.
All the time I have for now. I'll finish it up later.
ECCAD2
Regards @prash1730
Try this code...
First Apply "JOIN" to all the lines and polylines that represent the bars, then apply the "color_bar" routine, selecting all the blocks with the bar data.
;;;___
(defun c:color_bar (/ ltxn lc blkn ltxn ldx x y lc c sl atf pmin pmax
slw lp ang pn lpn)
(setq ltxn (vl-remove-if
'listp
(mapcar 'cadr (ssnamex (ssget '((0 . "INSERT")))))
)
)
(setq lc (list '(8 . "3")'(10 . "5")'(12 . "30")'(16 . "4")'(20 . "1")'(25 . "90") )
)
(foreach x ltxn
(setq ldx (entget (entnext (entnext x)))
atf (atoi (cdr (assoc 1 ldx)))
)
(foreach y lc
(if (= atf (car y))
(progn
(setq c (cdr y))
(vla-getboundingbox (vlax-ename->vla-object x) 'pmin 'pmax)
(setq pmin (vlax-safearray->list pmin)
pmax (vlax-safearray->list pmax)
sl (ssget "_c"
(mapcar '- pmin '(3. 0. 0.))
pmax
'((0 . "leader"))
)
lp (mapcar 'cdr
(vl-remove-if-not
'(lambda (j) (= (car j) 10))
(entget (ssname sl 0))
)
)
ang (/ pi 4)
lpn '()
)
(repeat 4
(setq pn (polar (car lp) ang 1.2)
lpn (cons pn lpn)
)
(setq ang (+ ang (/ pi 2)))
)
(setq slw
(ssname
(ssget "_cp"
lpn
(list '(0 . "*line") (cons 8 "Reinforcement"))
)
0
)
)
(vlax-put (vlax-ename->vla-object slw) 'Color (atoi c))
)
)
)
)
)
Carlos Calderon G
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Prash1730 - This change will report the re-rods into "ReRod-report.csv" in current folder.
Maybe you can use this additional data.
As before, just load it and type GO.
Cheers.
ECCAD
Namaste,
Thanks a lot @calderg1000 and @ec-cad i will check it out and revert. Once again thanks a lot for your valuable time.
Best regards,
PNP
Namaste,
@ec-cad i checked the lisp and it is changing the rebar colour perfectly! 👍👍
However, all the bars are in one layer - reinforcement. Can it be changed to say rein 12 for 12mm dia bar, rein 16 for 16mm dia bar and so on.. This will help in taking the length of only those dia meter bars which we are interested... Thanks a ton for your kind help @ec-cad
Best regards,
PNP
Prash1730,
Attached will make the Layers you requested..rein8mm rein10mm..etc. and will place each reinforcement bar
on that layer as well as change it's color to match..
Hope you like it. (again)
Cheers
ECCAD
Of course, I missed that call in the Lisp.
Here's the updated version.
Sorry about the trouble my bad.
ECCAD
prash1730,
I just ran it on the original 'drawing1' that you posted. Seems to work fine here.
When you appload and type GO at the command prompt, you may not notice anything but
a change in Color for those rods. But, there will be some Layers made, and the rods will be
changed to those Layers also.
At command prompt, after you do GO you might want to do the LAYWALK command.
Just type LAYWALK at the Command prompt. And look for items on those new layers.
Also, if nothing on the drawing you are working with changes, no new Layers ..
Please attach that drawing here for me to check out.
ECCAD
Namaste,
@ec-cad i tried again and found that new layers based on dia are being generated. However, they are not getting assigned to the respective rod diameters. Still all bars are diaplaying "Reinforcement" layer. Also, colour of the rods seems to be unchanged.
Attaching the file for your kind perusal.
Best regards,
PNP
The new drawing you attached kinda looks like the original, but it's not the same block set as original.
You have Text where the original drawing Block 'NO' was placed. So, as a consequence, the Lisp was looking
for the block NO, and it cannot find any on your new drawing. That 'block' insertion point and 2 attributes were
the key to grabbing the Leader, and at the insertion point of the Leader, grabbing the Pline.
See the attached 'checked' drawing for what is wrong.
So, I cannot help you any further on this topic, sorry.
ECCAD
prash1730,
I might have a solution. I'll check "Text" and look at the last character, if it's a (chr 216) I'll try
to break that down and use it's insertion point to start looking for the Leader..
working on it. If it works, I'll attach Do_Bars4.lsp.
ECCAD
Can't find what you're looking for? Ask the community or share your knowledge.