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

HELP PLEASE---error: bad argument type: 2D/3D point: (nil nil)

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
1173 Views, 8 Replies

HELP PLEASE---error: bad argument type: 2D/3D point: (nil nil)

I dont know anything about LISPs but here is the routine we have

 

;;
(defun varset ()
  (setq ap (getvar "attreq"))
  (setq osin (getvar "OSMODE"))
  (setvar "OSMODE" 0)
  (if (= ap 0)
    (progn
      (setvar "ATTREQ" 1)
      (setvar "ATTDIA" 0)
    )
  )
  (setq lnme (getvar "clayer"))
  (setq halfpi (/ PI 2))
  (setq 3hlfpi (* halfpi 3))
)
;;
;;
(defun c:lsr1al()
     (varset)
     (setq pent (car (entsel "\nPick the LASER object: ")))
     (print (setq begpt (getpoint "\nPick the beginning: ")))
     (setq albl (strcase (getstring "\nDo you wish to label the alignment?(Y/N) - ")))
     (print  "\nSelect the laser offset lines....  ")
     (setq ofset nil)
     (setq ofset (ssget '((0 . "LINE"))))
     (setq allst (entget pent))
     (setq ptx (car (cdr (assoc 10 allst))))
     (setq pty (cadr (cdr (assoc 10 allst))))
     (setq xy1 (list ptx pty))
     (setq ptx2 (car (cdr (assoc 11 allst))))
     (setq pty2 (cadr (cdr (assoc 11 allst))))
     (setq xy2 (list ptx2 pty2))
;
; CHECK BEGINNING
;
     (setq begchk (distance begpt xy1))
     (setq endchk (distance begpt xy2))
     (cond
        ((< endchk begchk)(progn
                             (setq begxy xy2)
                             (setq endxy xy1)))
        ((> endchk begchk)(progn
                             (setq begxy xy1)
                             (setq endxy xy2)))
     )
     (setq alang (angle begxy endxy))
     (sortr)
     (setq tbl (strcase (getstring "\nDo you wish to create an offset table?(Y/N) - ")))
     (if (or (= tbl "y")(= tbl "Y"))
        (listr)
     )
     (princ)
)
;;
;;
(defun sortr ()
  (setq ct2 0)
  (setq ct3 (sslength ofset))
  (setq outlst nil)
  (setq frst 1)
  (while (< ct2 ct3)
    (setq flg 0)
    (setq entnam (ssname ofset ct2))
    (PRINT (setq pntlst (entget entnam)))
    (setq ptx (car (cdr (assoc 10 pntlst))))
    (setq pty (cadr (cdr (assoc 10 pntlst))))
    (setq ptxy (list ptx pty))
    (setq ptx2 (car (cdr (assoc 11 pntlst))))
    (setq pty2 (cadr (cdr (assoc 11 pntlst))))
    (setq ptxy2 (list ptx2 pty2))
    (setq intang (angle begxy ptxy))
    (if (equal alang intang 0.00005)
        (progn
           (setq dst (distance begxy ptxy))
           (setq ofang (angle ptxy ptxy2))
           (setq flg 1)
           (setq prntof ptxy2)
        )
    )
    (if (= flg 0)
        (progn
           (setq dst (distance begxy ptxy2))
           (setq ofang (angle ptxy2 ptxy))
           (setq prntof ptxy)
        )
    )
    (setq len (* 12 (distance ptxy ptxy2)))
    (setq dsts (rtos dst 2 1))
    (setq lenarc (rtos len 4 2))
    (if (<= alang halfpi)
       (progn
          (setq angdif (- ofang alang))
          (if (> angdif PI)
              (setq dir " RT")
              (setq dir " LT")
          )
       )
    )
    (if (>= alang 3hlfpi)
       (progn
          (setq angdif (abs (- ofang alang)))
          (if (< angdif PI)
              (setq dir " RT")
              (setq dir " LT")
          )
       )
    )
    (if (and (> alang halfpi)(< alang 3hlfpi))
       (if (< ofang alang)
           (setq dir " RT")
           (setq dir " LT")
       )
    )
    (setq outdst (strcat dsts "ft"))
    (setq outof (strcat lenarc dir))
    (if (or (= albl "y")(= albl "Y"))
       (progn
          (if (= dir " LT")
             (setq ofang (+ ofang PI))
          )
          (setq dstpt (polar prntof ofang -12.0))
          (setq ofpt (polar prntof ofang 12.0))
          (setq ofangs (angtos ofang))
          (command "TEXT" "J" "MR" dstpt ofangs outdst)
          (command "TEXT" "J" "ML" ofpt ofangs outof)
       )
    )
    (setq outlin (strcat outdst "     " outof "\\P"))
    (if (/= frst 1)
       (setq outtab (strcat outtab outlin))
    )
    (if (= frst 1)
        (progn
            (setq frst 2)
            (setq outtab outlin)
        )
    )
    (setq ct2 (1+ ct2))
  )
)
;;
;;
(defun listr()
   (setq txtins (getpoint "\nPick the coordinate text insertion point: "))
   (command "MTEXT" txtins "W" 0 outtab "")
)
;;
;;

 

it gives me that error when i pick the offset lines

 

attached is a picture of what im working with..if you have any further questions please let me know

8 REPLIES 8
Message 2 of 9
fenton.webb
in reply to: Anonymous

Quickly looking at the code, not testing it, I can see that (ssget '((0 . "LINE")))) is missing the mode parameter e.g.

 

(ssget "_X" '((0 . "LINE"))))




Fenton Webb
AutoCAD Engineering
Autodesk

Message 3 of 9
Anonymous
in reply to: fenton.webb

I have no idea what that means... So I'll try to replace the one with the other

Sent from my iPhone
Email Disclaimer
Message 4 of 9
hmsilva
in reply to: Anonymous

Danelly03,
I didn't found nothing wrong with the code, attach a sample dwg, with some explanations how the code should work, so we can try to reproduce the error.

Henrique

EESignature

Message 5 of 9
Kent1Cooper
in reply to: Anonymous


@fenton.webb wrote:
Quickly looking at the code, not testing it, I can see that (ssget '((0 . "LINE")))) is missing the mode parameter e.g.

(ssget "_X" '((0 . "LINE"))))

 

@Anonymous wrote:
I have no idea what that means....

It doesn't necessarily need the mode parameter.  Without one, it's left to the User to select things, and it accepts only those that meet the filter criteria -- you can grab a whole Windowed or Crossing area, and also pick on individual objects, and use other object-selection options such as Remove, and when you hit Enter to complete the selection, it will "find" only the Lines among whatever was selected, and ignore everything else.  With the "_X" in there, it will find all Lines in the entire drawing, which I don't think is what you want.

Kent Cooper, AIA
Message 6 of 9
Anonymous
in reply to: hmsilva

The red line drawn through the '800' numbered points is the laser line...The white lines set every 5' are the offsets from the laser line to the center line....this lisp is suppose to have you select the laser line..the start end and all the offset lines and spit out the distance from the laser on one side and the lengt5h of the offset lines on the other....

in this drawing I hand entered all the text but the end result of the lisp should look like that

Thank you very much for your time and help


Danielle McCutchen

JS Redpath - Pogo

Phone: 907-895-2857
Email Disclaimer
Message 7 of 9
hmsilva
in reply to: Anonymous

Danielle,
I'm a metric guy, this was the main reason I asked for a dwg.
I tested the code, without errors (I think this is the intended result)

Danelly03.PNG

 

Henrique

EESignature

Message 8 of 9
Anonymous
in reply to: hmsilva

Well then I'm not sure what I'm doing wrong to get the error...

Sent from my iPhone
Email Disclaimer
Message 9 of 9
hmsilva
in reply to: Anonymous

Erase everything that is not necessary, except the lines to test the code, and attach your dwg, so we can try to reproduce the error.

Henrique

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost