Need help counting support quantities, can you please help?

Need help counting support quantities, can you please help?

israelU7LZU
Participant Participant
981 Views
43 Replies
Message 1 of 44

Need help counting support quantities, can you please help?

israelU7LZU
Participant
Participant

Good day to you Gentlemen,

 

I am not proficient in lisp programing, I don't quite understand the programing language. that's why I come seeking your help on this. 

 

I need to come up with a way to count supports quantities and add them up by height and create some sort of list in numerical order. is there a way to do these things?

 

please let me know what other info is needed to make this happen. 

 

Thank you 

0 Likes
982 Views
43 Replies
Replies (43)
Message 2 of 44

paullimapa
Mentor
Mentor

Thanks for sharing your drawing.

Perhaps you can explain more as to what are "supports quantities" that can be found in the sample drawing?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 44

Sea-Haven
Mentor
Mentor

Are you saying you want to know how many 8", 3-3/4", 11-1/4" and so on ?

 

May need a convert mtext to a decimal and back again etc

 

I may have something already it currently checks for blocks and makes a table result. It will cost you a cup of coffee. Watch this space.

0 Likes
Message 4 of 44

israelU7LZU
Participant
Participant

Good day Paul,

 

I replied to the email I got from AutoDesk when you replied to my question. did you get that email or do I need to reply here again? please let me know

 

0 Likes
Message 5 of 44

israelU7LZU
Participant
Participant

I also tried replying to the email I got from autodesk, can you let me know if you got the email please. if not, then I'll type it in here again. lol

0 Likes
Message 6 of 44

paullimapa
Mentor
Mentor

Unless you post your reply here others in the community like myself cannot see it since we don't work for autodesk.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 44

israelU7LZU
Participant
Participant
Hi Paullimapa, and thank you for taking the time to reply to my inquiry
 
In this type of work, we work with banded and uniform cables, which they need support at different heights. Please see Band Support Snap  and Uniform Support Snap, I would like to figure out how to count how many Supports (Chairs) are needed of each height and create a list in numerical order. Is that possible?
 
Please let me know if you have any questions about these drawings. 
 
Thank you very much for your help. 
0 Likes
Message 8 of 44

paullimapa
Mentor
Mentor

Not sure if there's a way to automate this.

But perhaps you can explain a bit further by looking at the below screenshot

paullimapa_0-1787197483369.png

I see 2 plines drawn on layer:: "TENDON-BANDED-BACKGROUND" 

There's a call out up top 8 SPA @ 36 1/2" and 8 SPA @ 36" drawn as DIMENSION on Layer: "DIMENSION-UNIFORM-SUPPORT"

Next there are all those 16 short but same length vertical plines drawn on Layer: "SUPPORT-BARS-BANDED"

These plines all have different #s on top such as 4 3/4", 3 1/4", 2 1/4", 2", 2 3/4", 5", 8 1/2" and etc. all as Mtext on Layer: "SUPPORT-TEXT-BANDED"

Now looking at this how do you manually count supports quantities and add them up by height and create a list in numerical order?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 44

israelU7LZU
Participant
Participant

every plines drawn on layer:: "TENDON-BANDED-BACKGROUND" is considered a bundle. 

those 16 short but same length vertical plines drawn on Layer: "SUPPORT-BARS-BANDED" are the support bars. 

the different #s on top such as 4 3/4", 3 1/4", 2 1/4", 2", 2 3/4", 5", 8 1/2" and etc. all as Mtext on Layer: "SUPPORT-TEXT-BANDED" are called "chairs"

 

having said that, for every so many bundles, we need a determined number of chairs. see below please. 

 

1 to 3 Bundles (TENDON-BANDED-BACKGROUND)= Needs 2 Support Chairs (SUPPORT-TEXT-BANDED)
4 to 5 Bundles (TENDON-BANDED-BACKGROUND) = Needs 3 Support Chairs (SUPPORT-TEXT-BANDED)
6 to 7 Bundles (TENDON-BANDED-BACKGROUND) = Needs 4 Support Chairs (SUPPORT-TEXT-BANDED)
8 to 9 Bundles (TENDON-BANDED-BACKGROUND) = Needs 5 Support Chairs (SUPPORT-TEXT-BANDED)

 

typically, I will find a chair height, for example 3 1/4", I will find all the chair height that are the same and figure out the quantity of chairs needed at the height based on the number of tendon bundles. on the snap you sent, there are two 3 1/4" chairs, and there are two bundles of cables, that means I need 2 chairs for every 3 1/4" height I find, since there are two of them. I know I need 4 chairs at 3 1/4" height. and I will repeat this for every different chair height and bundles I find. 

 

this is only for the Banded cables. then I have to do count the supports for the uniform cables which are done slightly different. I hope I was clear 

 

Thank you

0 Likes
Message 10 of 44

Sea-Haven
Mentor
Mentor

1st up this is a chair used in concrete slabs. They can be different heights and I think is what we are talking about.

SeaHaven_0-1787204752423.png

 

I think this is what you want, as the first step to select the chair text, I used;

(setq ss (ssget (list (cons 0 "MTEXT")(cons 8 "SUPPORT-TEXT-BANDED"))))

Then when asked to select you type "WP" this allows you to select a window on angle. If the dwg is horizontal then do not need the wp as a default selection is a window.

SeaHaven_2-1787204881856.png

PS 44 selected.

 

You now have a selection set of the chairs so can get text, sort and count how many of each type then multiply by the number of tendons. Working on it have an answer for blocks need to edit to match chairs text.

 

 

0 Likes
Message 11 of 44

Sea-Haven
Mentor
Mentor

Almost there just have to add multiply by number of tendons and sort the height correctly, need to convert like "2 1/2" to 2.5 etc so sort works correctly.

SeaHaven_0-1787209806531.png

Thanks to lee-mac for strip mtext and Gile for do count.

 

Also need to manually check count is correct, but shows something can be done.

 

The biggest problem is taking the mtext and convert to a decimal number, in the mtext there is like 4 variations in what is used, inches only, inch & fractions, fractions only, different text but with suffixes and again a mix of inches and fractions. Working on that.

0 Likes
Message 12 of 44

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

.... The biggest problem is taking the mtext and convert to a decimal number, in the mtext there is like 4 variations in what is used, inches only, inch & fractions, fractions only, different text but with suffixes and again a mix of inches and fractions. Working on that.


That's mostly not an issue, because the (distof) function can work with all of those possibilities except the suffixes.  It can handle it whether or not there is a fraction involved, whether or not [as some might do] you use a hyphen between inches and fractions, whether or not you include the inches mark at the end, and if the distances get big enough to include feet.  Even if the content is already a decimal number, with or without the inches mark, it can work with that, returning it as a decimal.  Assuming no other internal Mtext formatting [like font or color or height overrides] to complicate things, these all convert to good decimal equivalents for sorting:

Command: (distof "2 1/2\"")  with fraction and inches mark, without hyphen
2.5

Command: (distof "2-1/2\"")  with fraction and inches mark, including hyphen
2.5

Command: (distof "2-1/2")  with fraction and hyphen but no inches mark
2.5

Command: (distof "2")  no fraction, no inches mark
2.0

Command: (distof "2\"")  no fraction, with inches mark
2.0

Command: (distof "2'-2 3/4\"")  including feet
26.75

Command: (distof "2.5\"")  already decimal, with inches mark
2.5

But the suffix spoils it, so something would need to be done to pare it down to just the distance content.

Command: (distof "2-1/2\" S.B.")
nil

 

Kent Cooper, AIA
0 Likes
Message 13 of 44

israelU7LZU
Participant
Participant

Im sorry I'd been absent from the forum. I'd been busy counting supports by hand :D. I really appreciate the advances you have done on helping me resolve this matter. I would gladly compensate, if it is allowed, for all your help.  

0 Likes
Message 14 of 44

israelU7LZU
Participant
Participant

you are right about the chairs used in concrete slabs

0 Likes
Message 15 of 44

Sea-Haven
Mentor
Mentor

It is close keep going back to it, bit busy at moment.

 

@Kent1Cooper I found the simplest way was to split the text after removing the Mtext control into a List. Also remove inch ". Did look at distof and found the string problems.

"\\W0.8000;11 {\\A1;\\H0.7x;\\S1#4;}\"" = ("11" "1/4")

"\\A1; {\\H0.7x;\\S3#4;}\" S.B." = ("3/4" "S.B")

 

Then look at the list only the first and second item if it exists in list. 

 

Working on it, hopefully today.

0 Likes
Message 16 of 44

israelU7LZU
Participant
Participant
Hi Paullimapa, and thank you for taking the time to reply to my inquiry

In this type of work, we work with banded and uniform cables, which they need support at different heights. Please see Snap 1 and Snap 2, I would like to figure out how to count how many Supports (Chairs) are needed of each height and create a list in numerical order. Is that possible?

Please let me know if you have any questions about these drawings.

Thank you very much for your help.

Snap 1 Band Support

[cid:454e8255-03ee-481a-9afc-2c147986a1fe]

Snap 2 Uniform Support

[cid:38212a13-2b26-4f3e-95f1-5e6acae65fcd]



0 Likes
Message 17 of 44

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

.... Did look at distof and found the string problems.

"\\W0.8000;11 {\\A1;\\H0.7x;\\S1#4;}\"" = ("11" "1/4")

"\\A1; {\\H0.7x;\\S3#4;}\" S.B." = ("3/4" "S.B")

....


So there is [at least sometimes] internal Mtext formatting -- that would be necessary given the stacked fractions in the sample drawing.  Fortunately, the (getpropertyvalue) function can give you the text content either with or without that formatting.  If txt is a variable holding the entity name of this Mtext object [with its Contents showing in the Properties palette]:

Kent1Cooper_0-1787655318765.png

then you can pull that Contents string using (getpropertyvalue) instead of the (assoc 1) entry in entity data:

Command: (getpropertyvalue txt "Contents")
"\\A1;3 {\\H0.7x;\\S5#8;}\""

But you can get it without the formatting directly, using a different Property:

Command: (getpropertyvalue txt "Text")
"3 5/8\""

and then you can use (distof) on it as above.

Kent Cooper, AIA
0 Likes
Message 18 of 44

Sea-Haven
Mentor
Mentor

Thank you @Kent1Cooper for that idea, should be able to remove a defun that worked out fractions of a inch, need that for the sort function, make a list of (3.75  "3 3/4").

 

Give this a try. I did find one value sorted wrong for the entire dwg. Will look into why that happened. 

 

PLEASE CHECK COUNTS ! If incorrect let me know.

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/need-help-counting-support-quantities-can-you-please-help/td-p/14238558
; layer SUPPORT-TEXT-BANDED
;Take text and make them into a table 
; counting the text also
; by Alan H Aug 2026

(vl-load-com)

(defun AH:table_make (numcolumns txtsz / numrows curspc colwidth numcolumnsobjtable rowheight sp doc)
  (setq sp (vlax-3d-point (getpoint "Pick top left")))
  (setq doc(vla-get-activedocument (vlax-get-acad-object) ))
  (if (= (vla-get-activespace doc) 0)
    (setq curspc (vla-get-paperspace doc))
    (setq curspc (vla-get-modelspace doc))
  )
  (setq numrows 2)
  (setq rowheight txtsz)
  (setq colwidth 100)
  (setq objtable (vla-addtable curspc sp numrows numcolumns rowheight colwidth))
  (vla-settext objtable 0 0 "TABLE title")
  (vla-SetTextHeight Objtable (+ acDataRow acTitleRow acHeaderRow) txtsz)
  (vla-SetText Objtable 0 0 "Chairs")
  (vla-SetText Objtable 1 0 "Size")
  (vla-SetText Objtable 1 1 "Count")
  (setq obj2 (vlax-ename->vla-object (entlast)))
  (vla-Setcolumnwidth obj2 0 (* 6 txtsz))
  (vla-Setcolumnwidth obj2 1 (* 4.5 txtsz))
  (setq obj2 (vlax-ename->vla-object (entlast)))
  (princ)
)

; By Gile
(defun remove_doubles (lst)
  (if lst
    (cons (car lst) (remove_doubles (vl-remove (car lst) lst)))
  )
)

; By Gile
(defun my-count (a L)
    (cond
    ((null L) 0)
    ((equal a (car L)) (+ 1 (my-count a (cdr L))))
  (t (my-count a (cdr L))))
)


; Starts here 
;
(defun c:AHsupports ( / cnt lst lst2 lst3 obj2 rownum ss trow txtsz val x))
  (setq txtsz (getreal "Enter text size ")) ; try say 25
  (setq ss (ssget (list (cons 0 "MTEXT")(cons 8 "SUPPORT-TEXT-BANDED"))))
  (if (= ss nil)(progn (Alert "no items were selected will now exit ")(exit)))
  (setq lst '())
  (repeat (setq k (sslength ss))
	(setq textstr (getpropertyvalue (ssname ss (setq k (1- k))) "Text"))
    (princ "\n")
   (setq lst (cons (list (distof textstr) textstr) lst))
    (princ lst)
  )
  (setq lst (vl-sort lst '(lambda (i j) (< (car i)(car j)))))
  (setq lst3 '())
  (setq lst2 (remove_doubles lst))
  (princ lst2)
  (foreach val lst2
    (setq cnt (my-count val lst))
    (setq lst3 (cons (list val cnt) lst3))
  )
  (princ lst3)
  (AH:table_make 2 txtsz)
  (repeat (setq x (length lst3))
    (setq rownum (vla-get-rows obj2))
    (vla-InsertRows obj2 rownum (vla-GetRowHeight obj2 (- rownum 1)) 1)
    (setq trow (nth (setq x (1- x)) lst3))
    (vla-SetText Obj2 rownum 0 (cadr (car trow)))
    (vla-SetText Obj2 rownum 1 (rtos (cadr trow) 2 0))
  )
  (vla-SetTextHeight obj2 (+ acDataRow acHeaderRow acTitleRow) txtsz)
  (vla-SetAlignment obj2 acDataRow acMiddleCenter)
  (alert "To run again type AHsupports")
)
(c:AHsupports)

SeaHaven_0-1787700158144.png

 

0 Likes
Message 19 of 44

lauri_barnhart
Autodesk
Autodesk

Welcome to the community, @israelU7LZU.

 

Hope you are well. It looks like you have received a lot of information from paullimapa, Sea-Haven and Kent1Cooper. Did any of the information provided help clarify your question? If any of the posts provided the help, please consider clicking on the 'Accept Solution' button on the post(s) that helped. If you still need assistance, please update here.

 

Best,


Lauri | Community Manager
0 Likes
Message 20 of 44

israelU7LZU
Participant
Participant

Hi Sea-Haven,

 

is this the working lisp program? should I try it? I'm not sure how to create a lisp file, but Im guessing I can open an existing one, save it as, then erase everything in said file and copy/paste everything you show here? then load it up? what would the Key command be to start the program?

 

I really appreciate your help on this matter.  

0 Likes