Cad_Cae 板


LINE

※ 引述《dogcatbig (123)》之铭言: : 如题 : 因为小弟最近在看autocad程式设计 : autolisp+dcl+visual lisp篇这本 : (作者:吴永进、林美樱) : 范例50 : 做到一个例题是有统计图面上的图案 : (例如:圆形、正方形、直线) : 书上的程式描述能够自已点出数量 : 并绘出表格 : 可是小弟试的话并不行~ : 是不是小弟有什麽地方疏忽了 : 可以请教一下版上的高手吗? : 给小弟指点一下^^ : 谢谢 回文顺便问一个条件式: 总算是做到这个范例了,可是很奇怪,题目要求是统计"图块"而不是"图案", 莫非是版本的差异? (我的书上个月买进,版次:2008年6月初版) 我在执行这个范例时并没什麽大问题(不知道原po能不能再详细描述一下问题 是什麽?)不过有一个取出图块名称字首的条件式,看不懂它的用意是什麽: (setq blk_key (substr (cdr blkn) 1 1)) (if (/= blk_key "*")… 知道用意的热心板友请回板或站内信皆可,感谢! 另外,若如原po要求统计图案,好像只要把10test3 的例题和范例50的内容拼 凑一下就行了。但也遇到一个难解的情况:"正方形"的群码中似乎没有独立於 矩形、pline 的四边封闭围线或三段线的特徵码,计算数量时会把上述所有图 元全算进去…当然,也包括画在图面上的表格,所以会愈算愈多。 以下试作原po形容的问题,以及范例50的内容,(断行请记得接上): ===================================================================== (defun c:lsp50a() (setvar "cmdecho" 0) (setq os (getvar "osmode")) (setvar "osmode" 0) (command "style" "cc" "txt,chineset" "" "" "" "" "" "") ;画出表头 (setq pt1 (getpoint "\n左上角: ")) (setq ww (getdist pt1 "\n宽度 <60>: ")) (if (null ww) (setq ww 60.0)) (setq hh (getdist pt1 "\n每格高度 <8>: ")) (if (null hh) (setq hh 8.0)) (setq pt2 (polar pt1 0 ww)) (setq pt3 (polar pt2 (* pi 1.5) hh)) (setq pt4 (polar pt1 (* pi 1.5) hh)) (command "pline" pt1 pt2 pt3 pt4 "c") (setq pt5 (polar pt1 0 (/ ww 2))) (setq pt6 (polar pt5 (* pi 1.5) hh)) (command "pline" pt5 pt6 "") (command "text" "m" (inters pt1 pt6 pt4 pt5) (/ hh 2) 0 "图元类别") (command "text" "m" (inters pt5 pt3 pt2 pt6) (/ hh 2) 0 "数量") (setq type (getstring "\nChosse entity type:circle、line、arc、rectang: ")) (while (/= type "") (if (= type "rectang") (progn (setq type "LWPOLYLINE") (setq ss (ssget "x" (list (cons 0 type) (cons 90 4)))) (setq type "rectang") ) (setq ss (ssget "x" (list (cons 0 type)))) );endif (if (null ss) (setq count 0) (setq count (sslength ss)) );endif ;画出表格 (setq pt1 pt4 pt5 pt6 pt2 pt3) (setq pt4 (polar pt1 (* pi 1.5) hh)) (setq pt6 (polar pt5 (* pi 1.5) hh)) (setq pt3 (polar pt2 (* pi 1.5) hh)) (command "pline" pt2 pt3 pt4 pt1 "") (command "pline" pt5 pt6 "") (command "text" "m" (inters pt1 pt6 pt4 pt5) (/ hh 2) 0 type) (command "text" "m" (inters pt5 pt3 pt2 pt6) (/ hh 2) 0 (itoa count)) (setq type (getstring "\nEnter entity type (circle、line、arc、 rectang): ")) );end while (setvar "osmode" os) (prin1) ) (prompt "***************<<c:lsp50a>>***************") (prin1) ============================================================================== (defun c:lsp_50() (setvar "cmdecho" 0) (setq os (getvar "osmode")) (setvar "osmode" 0) (setq pt1 (getpoint "\n左上角: ")) (setq ww (getdist pt1 "\n宽度 <50>: ")) (if (null ww) (setq ww 40.0)) (setq hh (getdist pt1 "\n每格高度 <8>: ")) (if (null hh) (setq hh 8.0)) (setq pt2 (polar pt1 0 ww)) (setq pt3 (polar pt2 (* pi 1.5) hh)) (setq pt4 (polar pt1 (* pi 1.5) hh)) (command "pline" pt1 pt2 pt3 pt4 "c") (setq pt5 (polar pt1 0 (/ ww 2))) (setq pt6 (polar pt5 (* pi 1.5) hh)) (command "line" pt5 pt6 "") (command "text" "m" (inters pt1 pt6 pt4 pt5) (/ hh 2) 0 "图块名称") (command "text" "m" (inters pt5 pt3 pt2 pt6) (/ hh 2) 0 "数量") (setq blk (tblnext "block" t)) (while blk (setq blkn (assoc 2 blk)) ;这里看不懂用意是什麽 (setq blk_key (substr (cdr blkn) 1 1)) (if (/= blk_key "*") (progn (setq ss (ssget "X" (list blkn))) (if (null ss) (setq ssn 0) (setq ssn (sslength ss)) ) (setq blknn (cdr blkn)) (setq pt1 pt4 pt5 pt6 pt2 pt3) (setq pt4 (polar pt1 (* pi 1.5) hh)) (setq pt6 (polar pt5 (* pi 1.5) hh)) (setq pt3 (polar pt2 (* pi 1.5) hh)) (command "pline" pt2 pt3 pt4 pt1 "") (command "line" pt5 pt6 "") (command "text" "m" (inters pt1 pt6 pt4 pt5) (/ hh 2) 0 blknn) (command "text" "m" (inters pt5 pt3 pt2 pt6) (/ hh 2) 0 (itoa ssn)) ) ) (setq blk (tblnext "block")) ) (setvar "osmode" os) (prin1) ) --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.228.204.242
1F:→ phragmite:试了加上四边等长两角垂直的条件,应该可符合原po的要求 10/21 00:18
2F:→ phragmite: 线 10/21 00:21







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:e-shopping站内搜寻

TOP