乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 44|回复: 7

[编程交流] Help Please: LISP Loads, but C

[复制链接]

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 16:30:15 | 显示全部楼层 |阅读模式
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".
 
  1. ;;; 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))
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 16:41:03 | 显示全部楼层
Hint: One bracket is missing.
回复

使用道具 举报

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 16:52:02 | 显示全部楼层
 
Found it!
 
  1. (setq ptrotation (vlax-get sourcept 'rotation)[b])[/b]
 
Thanks!
回复

使用道具 举报

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 16:59:28 | 显示全部楼层
For anyone that wants the code...
 
  1. ;;; 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))
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 17:08:43 | 显示全部楼层
 
Correct.
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
362
发表于 2022-7-5 17:14:01 | 显示全部楼层
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?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:27:58 | 显示全部楼层
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
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:33:53 | 显示全部楼层
Another answer check brackets
 
  1. ; 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)
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-14 13:09 , Processed in 0.515773 second(s), 68 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表