Jump to content

Help with lisp


j_spawn_h

Recommended Posts

I want the block (btnl) to come in on the same side that i pick for the setq arr and arr2. If the line is going left to right then i will use arr to determined which side i want btnl. If the line is going up and down i would like for the block to use arr2.

 

(defun c:td (/); layerset hr raf1 raf2 ss en ed p10 p11 mpt d2d d1d d3d d4d lan tan fg hg)
 (defun errorhandler (s)
(if (/= s "Function cancelled")
   (princ (strcat "\nError: " s))
   (princ "SW function cancelled!"))
(setvar "clayer" layerset)
(setvar "orthomode" orthoset)
(setvar "osmode" osset)
(setvar "cmddia" cmddiaset)
(setvar "attdia" attdiaset)
(setvar "regenmode" 1)
(setq *error* olderr)
(princ))
;;;;----set variables -------------------------------------
 (setq layerset (getvar "clayer"))
;;;;----Pick Tendon for Layer isolation--------------
 (entsel "\n Select a line on Slab Tendon Line Layer")
   (while (= hr nil)
    (setq hr (entsel))
     );end while
    (setq stlay (cdr (assoc 8 (entget (car hr)))));stlay-layer for slab tendon
 (entsel "\n Select a line on Beam Tendon Line Layer")
  (while (= hr1 nil)
    (setq hr1 (entsel))
    );end while
    (setq btlay (cdr (assoc 8 (entget (car hr1)))));btlay-layer for beam tendon
   
  (command "_.layer" "s" "s-tend-beam" "")
  (command "_.layer" "off" "*" "n" "")
  (command "_.layer" "on" stlay "")
  (command "_.layer" "on" btlay "")
     (command "textsize" "6" "")
(command "_.style" "romans" "0" "0.80" "" "" "" "")
 ;;;;-----Get point for arrow side-------------------
 (setq arr (getpoint "Pick first side you want the Live end"))
 (setq arr2 (getpoint "Pick second side you want the Live end"))
   
(and (setq ss (ssget "_:L" '((0 . "LINE"))))
    (while (setq en (ssname ss 0))
           (setq ed (entget en))
           (setq p10 (cdr (assoc 10 ed)))
           (setq p11 (cdr (assoc 11 ed)))
           (setq mpt (mapcar '(lambda (a b) (* (+ a b) 0.5)) p10 p11))
           (setq d2d (+ (distance (cdr (reverse p10)) (cdr (reverse p11))) 4.0))
           (setq d1d (/ d2d 12.))
           (setq d1c (fix (+ d1d 0.501)))
           (if (> d1d d1c)
        (setq d2c (+ d1c 1)))
           (if (<= d1d d1c)
        (setq d2c d1c))
           (if (>= tend 9.0)
        (setq d3c (* (fix (+ (/ d2c 2.0) 0.5)) 2.0))
        (setq d3c d2c))
                      
  
;-------TENDON JUSTIFICATION----------------------------------------     
      (setq lan (angle p10 p11))
;(setq ad (radians->degrees lan))    ;angle degrees
      (if (and (> ad 90.1) (<= ad 270.1)) ;round off error
        (progn
          (setq ptemp p10)
          (setq p10 p11)
          (setq p11 ptemp)
          (setq lan (angle p10 p11))       ;angle radians
          (setq ad (radians->degrees lan))
   );end progn
 );end if
                
      (setq dir (if (< (* pi 0.5) lan (* pi 1.5)) - +))
;-----------------INSERT TENDON                  
     (setq btnl "btenl")
      (setq btnd "btend")
      (command "_.insert" btnl p10 "30" "" ad "")
      (command "_.insert" btnd p11 "30" "" ad "")
       
                  (ssdel en ss)))
 (command "_.layer" "on" "*" "" "")
(setvar "clayer" layerset)
 
 
  (prin1))

Link to comment
Share on other sites

If I understand you correct its easy when you pick the line you compare the distance to start and end the closest end is considered as the left end block always goes to the right of the line.

 

(SETQ TP1 (entsel "\nSelect inside wall near left end: "))
 (setq tpp1 (entget (car tp1)))
  (setq p1 (cdr (assoc 10 tpp1)))
 (setq p2 (cdr (assoc 11 tpp1)))
 (setq p3 (cadr tp1))
  (setq d1 (distance p1 p3))
 (setq d2 (distance p2 p3))
   (if (> d1 d2)
   (progn
   (setq temp p1)
   (setq p1 p2)
   (setq p2 temp)
   )
   )    

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...