Jump to content

Recommended Posts

Posted

Ok first of all, thank you all for helping me when I come here. This lisp is a combo of different lisps and I have been trying to modifiy it to do things for me. I am at a point where I do not know what is wrong could someone help please. This is the error I get when I run it.

"; error: bad argument type: 2D/3D point: (2898.99)"

What I am trying to do is label multible polylines with their lengths thats been rounded up. The text should always be on top of the line and read from top to bottom or from left to right.

(defun c:pt (/ 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))
(setq layerset (getvar "clayer"))
;----------PICK WHICH LINES YOU WANT TO LABEL-------------  
 (setq hr (getstring "\nCeiling or Ridges?(C/R): "))
  (if (= hr "c")
    (progn
  (command "_.layer" "s" "s-frm-cjoist" "off" "*" "n" "on" "s-anno-text" "s" "s-anno-text" "" "")))
    (if (= hr "r")
      (progn
 (command "_.layer" "s" "s-frm-roof" "off" "*" "n" "on" "s-anno-text" "s" "s-anno-text" "" "")))
  (command "textsize" "6" "")
(command "_.style" "jaytxt" "romans" "0" "0.80" "" "" "" "")

(and (setq ss (ssget '((0 . "*polyline"))))
    (while (setq en (ssname ss 0))
           (setq ed (entget en))
           (setq p10 (cdr (assoc 10 ed)))
           (setq p9 (reverse ed))
           (setq p11 (cdr (assoc 10 p9)))
           (setq mpt (mapcar '(lambda (a b) (* (+ a b) 0.5)) p10 p11))
           ;(setq d2d (distance (cdr (reverse p10)) (cdr (reverse p11))))
           (setq d2d (distance (cdr p10)(cdr p11)))
           (setq d1d (/ d2d 12.))

        (setq d4d (fix (* (+ (/ d1d 2.0) 0.5)2.0)))
;------ROUNDING--------------------   
      (defun even (n)
 (if (zerop (rem n 2)) n (1+ n)))

;-------TEXT JUSTIFICATION----------------------------------------     
      (setq lan (angle p10 p11))
(setq ad (radians->degrees lan))   
      (if (and (> ad 90.1) (<= ad 270.1)) 
        (progn
          (setq ptemp p10)
          (setq p10 p11)
          (setq p11 ptemp)
          (setq lan (angle p10 p11))       
          (setq ad (radians->degrees lan))))
      ;(if (> lan 4) (setq lan 1.57079))
            ;(if (> lan 4)(< lan 5) (setq lan lan))
            ;(if (> lan 3) (setq lan (- lan pi)))
            ;(if (> lan 2) (setq lan (+ lan pi)))

      (setq dir (if (< (* pi 0.5) lan (* pi 1.5)) - +))
           ;(setq tan (if (> (* pi 1.5) lan (* pi 0.5)) (+ lan pi) lan))

           (setq r3(entmake (list (cons 0 "TEXT")
                          (cons 8 (getvar "CLAYER"))
                          (cons 7 (getvar "TEXTSTYLE"))
                          (cons 40 (getvar "TEXTSIZE"))
                          (cons 41 0.80)
     (cons 72 4)
            (setq fg(cons 10 (setq r1(polar mpt (dir lan (+ 1)) ;(* pi 0.5))
                                   (getvar "TEXTSIZE")))))
                          (setq hg(cons 11 (setq r2(polar mpt (dir lan (+ 1)) ;(* pi 0.5))
                                   (getvar "TEXTSIZE")))))
                          (setq gg(cons 50 lan))
                         (cons 1 (strcat (itoa (even d4d)) "'")))))



                  (ssdel en ss)))
 (command "_.layer" "on" "*" "" "")
(setvar "clayer" layerset)


  (prin1))

Posted

It's your d2d variable.

(distance (cdr p10)(cdr p11)) is producing the error.

It should just be (distance p10 p11).

I also didn't see your radians->degrees function.

This would suffice if you don't have one:

(defun radians->degrees ®(cvunit r "radian" "degree"))

Posted

Today 03:11 pm

jvillarreal,

thank you that works great. Now I can start trying to make it do other stuff for me.

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...