Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Calculating stirrup length

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
k005
708 Views, 15 Replies

Calculating stirrup length

Hi all,

 

I have column names like this and slightly different. (before example in attached file)

 

Can I print the stirrup size from these?

 

example is attached. The formula is given.

 

 

SZ12 (60/30)
SZ16 (30/95)
SZ01 (30/95)
SZ13 (95/30)
SZ06 (30/95)
SZ22 (30/95)
SZ14 (60/30)
SZ15 (60/30)
SZ20 (40/40)
SZ21 (40/40)
SZ05 (40/40)
SZ04 (30/60)
SZ11 (60/30)
SZ10 (60/30)
SZ19 (30/60)
SZ18 (30/60)
SZ09 (60/30)
SZ03 (40/60)
SZ02 (30/60)
SZ07 (60/30)
SZ08 (60/30)
SZ17 (30/60)

 

 

Thanks in advance my friend.

 

 

15 REPLIES 15
Message 2 of 16
Kent1Cooper
in reply to: k005

Questions:

 

Which of the four different Before conditions would you actually have?  It makes a big difference to the approach, whether an "entry" consists of one Text object or two, and/or whether parentheses are involved.

 

Does the After really make no reference to the SZxx name in each case?  In the case of the SZxx being a separate Text object from the YY/ZZ [or (YY/ZZ)] part, does the SZxx part have any relevance at all?

 

What would be the User procedure?  Call a defined-command name, and then ... ?

 

Assuming the two numbers such as 30 and 60 are extracted from a Text string and put into variables called n1 and n2, in AutoLisp terms and reduced down to what it really amounts to, L would be (* (+ n1 n2 1) 2).

Kent Cooper, AIA
Message 3 of 16
k005
in reply to: Kent1Cooper

 

There can be four different formats, so I sampled it...

 

Sxx doesn't matter. The main thing is the */* format that we should use for the formula. Like 30/60.

 

Sxx does not have a name like YY or ZZ.

 

5ø8 -> this is a text object. L=xxx -> this is another separate text object. On the same axis...

Message 4 of 16
Kent1Cooper
in reply to: k005


@k005 wrote:

....

Sxx does not have a name like YY or ZZ.

....


[I'm not sure what you mean by that part.  My YY/ZZ was a stand-in for 30/60, 60/30, 40/40, 30/95, whatever.]

 

One question is still unanswered, and I have another:  Would the numbers always be 2 digits?

Kent Cooper, AIA
Message 5 of 16
k005
in reply to: Kent1Cooper

 

I'm sorry, I thought you were asking in terms of labels...

 

yes, changing their location does not change anything with L=xxx length. the result will be the same.

 

** Yes always two digits

Message 6 of 16
Kent1Cooper
in reply to: k005

Still no answer on the User procedure, and related issues.  The User selects a Text object?  Or a bunch of them at once?  Or the routine finds them all, based on some criterion [that they contain a YY/ZZ part, and/or by their Layer or Style, or...]?  Will they always be in vertical columns or at least always with space to their right so the added Text won't overlap something?  Would the Layer for the new Text be built into the code, or would the User be asked to specify it, or would it be the same as the selected Text?  LIkewise for the Style and height.  Would the added Text be in a different color, as in your sample drawing, or was that just to visually differentiate before from after?  Etc., etc.

Kent Cooper, AIA
Message 7 of 16
k005
in reply to: Kent1Cooper

 

not always vertical columns. It can be horizontal. or mixed

 

* may be green in color.

 

* font size can be the same as selected.

 

* 5ø8 L=xxx format Sxx xx/xx can also be written just below the selected one. or collectively as a vertical column...

 

******         ***        Attach ****

 

Message 8 of 16
Kent1Cooper
in reply to: k005


@k005 wrote:

.... or collectively as a vertical column...


That's a lot easier than having to figure out somehow whether to put results beside or below [what if some would need to be in one direction and some in the other?].  Try this [minimally tested], which asks you to position the first 5ø8 Text for the top of the column of results:

 

(defun C:STIRLEN (/ ss txt ht hor ver n ref str n1 n2); = STIRrup LENgths
  (if
    (setq ss (ssget '((1 . "*##/##*"))))
    (progn ; then
      (command "_.copy" (ssname ss 0) "" '(0 0 0) ""); in place
      (setpropertyvalue (setq txt (entlast)) "TextString" "5ø8")
      (setpropertyvalue txt "Color" 3)
      (alert "Position Text for top of vertical column of values.")
      (command-s "_.move" txt "" "_non" (getpropertyvalue txt "Position"))
      (setq
        ht (getpropertyvalue txt "Height")
        hor (* ht 3)
        ver (* ht 1.5)
      ); setq
      (repeat (setq n (sslength ss))
        (setq
          ref (ssname ss (setq n (1- n)))
          str (getpropertyvalue ref "TextString")
          str (substr str (1- (vl-string-search "/" str)) 5); ##/## part only
          n1 (atoi (substr str 1 2))
          n2 (atoi (substr str 4))
        ); setq
        (command "_.copy" txt "" "_non" (polar '(0 0) 0 hor) "")
        (setpropertyvalue (entlast) "TextString" (strcat "L=" (itoa (* (+ n1 n2 1) 2))))
        (if (> n 0)
          (progn ; then
            (command "_.copy" txt "" "_non" (polar '(0 0) (* pi 1.5) ver) "")
            (setq txt (entlast))
          ); progn
        ); if
      ); repeat
    ); progn
  ); if
  (prin1)
); defun

 

The second setting of the 'str' variable [done in a way that doesn't care whether there are parentheses and/or a SZ## prefix], and the setting of 'n1' and 'n2', are why it matters that the numbers are always and only 2 digits each.

Kent Cooper, AIA
Message 9 of 16
calderg1000
in reply to: k005

Regards @k005 

Try this code. Select texts with a format similar to the second attached file

(defun c:l_s (/ s lst i sn tx pr cx a b l rs pins)
  (princ "Select texts with <SZxy (ij/kl)> format: ")
  (setq s   (ssget '((0 . "text")))
        lst ()
  )
  (repeat (setq i (sslength s))
    (setq sn  (entget (ssname s (setq i (1- i))))
          tx  (cdr (assoc 1 sn))
          pr  (substr tx 1 4)
          cx  (substr tx 7 5)
          a   (atof (substr cx 1 2))
          b   (atof (substr cx 4 2))
          l   (rtos (+ (* 2 (- a 6)) (* 2 (- b 6)) (* 2 13)) 2 2)
          rs  (strcat pr " L= " l "\\P")
          lst (cons rs lst)
    )
  )
  (setq ltx  (apply 'strcat (vl-sort lst '<))
        pins (getpoint "\nPickpoint: ")
  )
  (entmakex (list '(0 . "MTEXT")
                  (cons 100 "AcDbEntity")
                  (cons 100 "AcDbMText")
                  (cons 10 pins)
                  (cons 40 20)
                  (cons 1 ltx)
                  (cons 11 '(1. 0. 0.))
            )
  )
)

 


Carlos Calderon G
EESignature
>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.

Message 10 of 16
k005
in reply to: Kent1Cooper

 

Thanks a lot, editor. Yes, this way. It was very nice. 🤗

 

 

 

 

 

 

Message 11 of 16
k005
in reply to: calderg1000

 

This is not exactly what I want. but it's nice to have the column names (Sxx) sorted. I accept it as an alternative.

 

As for the 5ø8 part; I'll add it too. I know some lisp. 😉

 

Thank you so much.

 

Respects.

Message 12 of 16
Sea-Haven
in reply to: k005

Just a comment from an ex structural engineer why not have a full lisp that draws all the column details, that includes to correct world location standards. I  also noticed the name how many times has K005 asked for freebies now. 

 

I would have bought a 3rd party program that does just that and way much more, eg STRUCPLUS.

 

But some out there just want freebies. Or is it a case of they are screwed by higher up compared to what they are paid.

 

 

Message 13 of 16
k005
in reply to: Sea-Haven

I expect a response from you on my next question, sir.

Message 14 of 16
Sea-Haven
in reply to: k005

Did you look at Strucplus ?

Message 15 of 16
k005
in reply to: Sea-Haven

Yes.

Message 16 of 16
calderg1000
in reply to: k005

Ok, I hope you can complement it. Glad to help

Carlos Calderon G
EESignature
>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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report