Help Please: LISP Loads, but C
I copied an existing routine that I have and tweaked it to match a point marker rotation. It will load successfully, but CAD then says "Unknown Command".;;; match point marker rotation(defun c:MPMR (/ doc labelstyle layr lblstyle newstyle obj obj2 pt ptdesc ptlayer ptstyle sourcept ss ss2 lblRot)(vl-load-com)(setq doc (vla-get-activedocument (vlax-get-acad-object)))(vla-startundomark doc)(princ "\nSelect source point: ")(if (setq ss (ssget ":S" '((0 . "AECC_COGO_POINT"))))(progn(setq sourcePt (vlax-ename->vla-object (ssname ss 0)))(setq ptrotation (vlax-get sourcept 'rotation)(princ "\n....select Points to change: ")(if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))(while (> (sslength ss) 0)(setq pt (vlax-ename->vla-object (ssname ss 0)))(vlax-put pt 'rotation ptrotation)(ssdel (ssname ss 0) ss)))))(vla-endundomark doc)(princ)) Hint: One bracket is missing.
Found it!
(setq ptrotation (vlax-get sourcept 'rotation))
Thanks! For anyone that wants the code...
;;; match point block rotation(defun c:MPBR (/ doc labelstyle layr lblstyle newstyle obj obj2 pt ptdesc ptlayer ptstyle sourcept ss ss2 lblRot)(vl-load-com)(setq doc (vla-get-activedocument (vlax-get-acad-object)))(vla-startundomark doc)(princ "\nSelect source point: ")(if (setq ss (ssget ":S" '((0 . "AECC_COGO_POINT"))))(progn(setq sourcePt (vlax-ename->vla-object (ssname ss 0)))(setq ptrotation (vlax-get sourcept 'rotation))(princ "\n....select Points to change: ")(if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))(while (> (sslength ss) 0)(setq pt (vlax-ename->vla-object (ssname ss 0)))(vlax-put pt 'rotation ptrotation)(ssdel (ssname ss 0) ss)))))(vla-endundomark doc)(princ))
Correct. FWIW - in the future, you can easily debug this yourself if you're using the VLIDE.
A quick click of the "Check" button would have told you this --> "Error: malformed list on input".
Even so, when you loaded the code, it told you the same thing. I suppose you just missed this on the command line? FWIW, I have created an Error Message Troubleshooter to help diagnose the typical causes of common AutoLISP error messages.
On receiving the error 'malformed list on input' this would have indicated that you were missing a closing parenthesis.
Lee Another answer check brackets
; By Alan H; circa 1980's(defun c:chkbrk (/ opf bkt chekdfile rdctl wkfile currentln wln ltr ncln)(setvar "cmdecho" 0)(prompt "\nlook at end of line");(setq chekdfile (getstring "enter name of file :"))(SETQ chekdfile (getfiled "Enter file name:" " " "LSP" 4))(setq opf (open chekdfile "r"))(setq bkt 0)(setq blkl 0)(setq rdctl 1)(setq wkfile (open "c:\temp\wow.lsp" "w"))(setq currentln "a")(while (/= blkl 6)(setq currentln (read-line opf))(if (= currentln nil)(setq currentln ""))(if (= currentln "")(setq blkl (+ 1 blkl))(setq blkl 1))(setq wln currentln) (while (/= wln "") (setq ltr (substr wln 1 1)) (setq wln (substr wln 2)) (cond ((= (ascii ltr) 34) (if (= rdctl 0)(setq rdctl 1)(setq rdctl 0))) ((and (= ltr "(")(= rdctl 1))(setq bkt (+ bkt 1))) ((and (= ltr ")")(= rdctl 1))(setq bkt (- bkt 1))) ((and (= ltr ";")(= rdctl 1))(setq wln "")) ;(t (prompt ltr)) ))(setq ncln (strcat currentln ";" (itoa bkt)(princ (itoa bkt))(if (= rdctl 0) "string open" "")))(if (/= currentln "")(write-line ncln wkfile)))(close wkfile)(close opf)(prompt (strcat "open brakets= " (itoa bkt) ".")))(command "chkbrk")(princ)
页:
[1]