乐筑天下

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

[编程交流] Dimsum ... Help w/ a Mod =)

[复制链接]

32

主题

98

帖子

66

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
160
发表于 2022-7-5 16:53:40 | 显示全部楼层 |阅读模式
Hey everyone I have been using this lisp forever and always wanted a function added and have no idea how to add it. Props to Tony Hotchkiss for writing this great lisp.  I wanted to add the function of once it is added together that it shows the answer like it does now, BUT then asks you if you want to divide the answer and by how many times and shows that answer.  Here is the lisp from Tony ....
 

[code];;;12345678901234567890123456789012345678901234567890;;; DIMSUM.LSP a program to extract the sum of;;; all selected dimension texts.;;; Program by Tony Hotchkiss for R14.(defun dxf (code ename) (cdr (assoc code (entget ename)))) ;_ end of defun(defun dimsum () (setq ss nil) (prompt "\nSelect dimensions: ") (while (not ss)   (setq ss (ssget '((-4 . ""))            ); ssget   ); setq   (if ss     (progn       (setq dims 1)     ); progn     (progn       (prompt        "\nNo dimensions selected; select again: "       ) ;_ end of prompt       (setq dims 0)     ); progn   ); if ) ;_ end of while (setq d-m-lists (categorize ss)       mlist1  (do-dims (car d-m-lists))       mlist2  (do-mtxt (cadr d-m-lists))       mlist (append mlist1 mlist2) ); setq (setq n 0 txtlist nil) (repeat (length mlist)   (setq mtxt (nth n mlist))   (setq txt (mtxt-2-txt mtxt))   (setq txtlist (append txtlist (list txt)))   (setq n (1+ n)) ); repeat (setq numlist (mapcar 'atof txtlist)) (setq sumtotal (apply '+ numlist)) (print (strcat "Total length of selected "        "dimensions is: "         (rtos sumtotal 2 4) " or "        (rtos sumtotal 5 4) )); print and strcat (princ)) ;_ end of dimsum(defun categorize (ss) (setq k        (- 1)       dim-list nil       txt-list nil ); setq (repeat (sslength ss)   (setq ename        (ssname ss (setq k (1+ k)))         etype (dxf 0 ename)   ); setq   (if (= etype "DIMENSION")     (setq dim-list (append dim-list (list ename)))     (setq txt-list (append txt-list (list ename)))   ); if ); repeat (list dim-list txt-list)); categorize(defun do-dims (dlist) (setq mv-list nil) (repeat (length dlist)   (setq bname   (dxf 2 (car dlist))  blist   (tblsearch "BLOCK" bname)         ent     (cdr (assoc -2 blist))         got-it  nil   ) ;_ end of setq   (while (not got-it)     (setq etype (dxf 0 ent))     (if (= etype "MTEXT")       (progn         (setq mtxt-val (dxf 1 ent)               got-it   T         ); setq       ); progn     ); if     (setq ent (entnext ent))   ); while   (setq mv-list (append mv-list (list mtxt-val))         dlist   (cdr dlist)   ); setq ); repeat mv-list) ;_ end of do-dims(defun do-mtxt (m-list) (setq mv-list nil) (repeat (length m-list)   (setq ent      (car m-list)         mtxt-val (dxf 1 ent)   ); setq   (setq mv-list  (append mv-list (list mtxt-val))         m-list   (cdr m-list)   ); setq ); repeat mv-list); do-mtxt(defun nextchar (j) (setq char (substr mtxt j 1)))(defun mtxt-2-txt (mtxt) (setq k     1       bslsh "\134"       txt   ""       len   (strlen mtxt) ); setq (while (
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:37:19 | 显示全部楼层
ok 1st "sumtotal" no checking done but a good guess not tested
 
add this at end of dimsum
 
  1. (setq num (Getreal "enter number"))
  2. (alert (strcat (Rtos num 2 0) " divisor interval = " (rtos (/ sumtotal num) 2 0)))
  3. ) ;_ end of dimsum
  4. [code]
  5.  
  6. Ps here in AUS we have DIM SIMS.
回复

使用道具 举报

32

主题

98

帖子

66

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
160
发表于 2022-7-5 18:01:49 | 显示全部楼层
Thanks Al !! ... Worked perfect !!
I just changed the output reading for 4 decimals
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-6 11:12 , Processed in 0.288002 second(s), 59 queries .

© 2020-2025 乐筑天下

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