明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: soonsos

[讨论] 求能够连续测量多点间距的lsp程序

  [复制链接]
发表于 2011-1-25 18:02 | 显示全部楼层
直接写一个程序不就可以了吗,这样的程序有不难。
 楼主| 发表于 2011-1-26 20:44 | 显示全部楼层
9楼的方法我也想过,整合到一个程序里面。问题是我要具体的程序呀!!!谁能编出来!!
发表于 2011-1-26 20:54 | 显示全部楼层
求多点距离,并显示在屏幕
  1. (defun c:dd (/ pt pts dis p1 pp ppp );连续测量线段总长
  2.   (setvar "cmdecho" 0)
  3.   (setq K (getvar "dimscale"))
  4.   (setq t_h (* 3 k))
  5.   (command "style" "xywzgs" "txt,hztxt" t_h 0.8 0 "n" "n" "n")         
  6.   (while (setq pt (getpoint "\n请选取点: "))
  7.    
  8.     (if        (not p1)
  9.            (setq p1 pt)
  10.       
  11.     )
  12.    
  13.     (setq pts (cons pt pts))
  14.     (if (>= (length pts) 2)
  15.      (grdraw pt p1 1))
  16.     (setq p1 pt)
  17.   )
  18.   (setq dis 0.)
  19.   (if pts
  20.     (mapcar '(lambda (x y)
  21.                (setq dis (+ dis (distance x y)))
  22.              )
  23.             (reverse (cdr (reverse pts)))
  24.             (cdr pts)
  25.     )
  26.           )
  27.   ;;(apply 'command (cons ".pline" pts))
  28.   ;;(command)
  29.   (if (not (zerop dis))
  30.      (progn
  31.      (setq pp (* 0.001 dis))
  32.      (setq ppp (rtos pp 2 3))
  33.         (princ (strcat "\n线段总长 = " ppp "米\n"))
  34.     (command "Text" "s" "xywzgs" p1 "0" PPP )
  35.     (command "move" "L" "" "@" )
  36.      ))
  37.   (princ)
  38. )
 楼主| 发表于 2011-1-28 00:28 | 显示全部楼层
13楼的程序恐怕是抄的网上的,里面依旧使用了grdraw函数,这个函数有个不好的地方就是:鼠标移动后,grdraw函数产生的红色轨迹就消失了,以致使用者不知道侧料到何处了!!!
发表于 2011-1-28 03:40 | 显示全部楼层
本帖最后由 caoyin 于 2011-1-28 04:24 编辑
chg 发表于 2011-1-23 21:56
dist 命令里不是有个多点选项吗?


可能低版本的cad没有,但我的是2011是有多点选项的
命令: DIST
指定第一点:
指定第二个点或 [多个点(M)]: m
指定下一个点或 [圆弧(A)/长度(L)/放弃(U)/总计(T)] <总计>:

写一个也很方便:
;;;;以下代码引用置顶贴子的函数 http://bbs.mjtd.com/thread-85250-1-1.html


  1. ;;;以下代码引用置顶贴子的函数 http://bbs.mjtd.com/thread-85250-1-1.html
  2. ;;;by caoyin 2011.1.28
  3. (defun C:DIT (/ P1 PW  P2 OBJ DI)
  4.   (initget "Object")
  5.   (setq P1 (getpoint "\n指定第一点或 [对象(O)] <对象>: "))
  6.   (if (vl-consp P1)
  7.     (progn
  8.       (setq PW (getvar 'PLINEWID))
  9.       (setvar 'PLINEWID 0)
  10.       (command "_.PLINE" P1)
  11.       (while (setq p2 (getpoint p1 "\n指定下一点: "))
  12.         (command P2)
  13.         (setq P1 P2)
  14.       )
  15.       (command "")
  16.       (setq OBJ (list (entlast)))
  17.       (setvar 'PLINEWID PW)
  18.     )
  19.     (if (setq OBJ (ssget '((0 . "LINE,*POLYLINE,ARC,CIRCLE,ELLIPSE,SPLINE"))))
  20.       (setq OBJ (MJ:SS->LIST OBJ))
  21.     )
  22.   )
  23.   (setq DI (apply '+ (mapcar '(lambda (x)
  24.                                 (vlax-curve-getdistatparam X (vlax-curve-getendparam X))
  25.                               )
  26.                               OBJ
  27.                      )
  28.            )
  29.   )
  30.   (MJ:Print-LIST
  31.     (list "总长度=" (MJ:RTOS DI) "。")
  32.   )
  33.   (if (vl-consp P1) (entdel (car OBJ)))
  34.   (princ)
  35. )





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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-6-8 03:40 , Processed in 0.192000 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表