明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2451|回复: 3

单线变双线能不能改成这样

[复制链接]
发表于 2014-7-20 20:46:00 | 显示全部楼层 |阅读模式
2明经币
这是论坛里以为兄弟的单线改双线的源码

;**********************************单线变双*************************
(defun c:bs (/ oldlayer dis o)
  (prompt "***单线变双线***")
  (command "undo" "be")
  (setq oldlayer (getvar "CLAYER"))
  (setvar "cmdecho" 0)
  (command "-layer" "M" "管径" "" "Color" 2 "" "l" "continous" "" "")
(setq dis (getreal "\n输入双线间的距离:"))
  (setq o 1)
  (while o
    (setq o nil)
    (setq o (entsel "\n选择要变双的线条< (右键退出)"))
    (command "offset" (/ dis 2) o '(-9999999 -9999999) "")
    (command "change" (ssget "l") "" "p" "la" "管径" "")
    (command "offset" (/ dis 2) o '(9999999 9999999) "")
    (command "change" (ssget "l") "" "p" "la" "管径" "")
    (command "erase" o "")
  )
  (setvar "CLAYER" oldlayer)
  (command "undo" "e")
)

能不能改成这样,人工输入一条虚线(直线或多义线)(并自动归入自定义的图层1),以这条虚线为基准,再给出双线间的距离,形成的实线线型的pline线,线宽w 为30,(并归入自定义的图层2),完成以上操作后,以输入的虚线中点放大1.5倍,本人基础太差,现在还不能独立修改,那位帮帮忙,给改一下

具体见下图

附件: 您需要 登录 才可以下载或查看,没有账号?注册

最佳答案

查看完整内容

我改了一下,试验好使~ 你试试吧~ (defun c:bs() (command "undo" "be") (command "celtype" "ACAD_ISO03W100") (setq pt1 (getpoint "请选择第1点")) (princ "\n") (setq pt2 (getpoint "请选择第2点")) (princ "\n") (command "line" pt1 pt2 "") (setq o1 (entlast)) (command "change" o1 "" "p" "la" "zdy1" "") (command "celtype" "Continuous") (setq dis (g ...
发表于 2014-7-20 20:46:01 | 显示全部楼层
我改了一下,试验好使~  你试试吧~

(defun c:bs()
    (command "undo" "be")
    (command "celtype" "ACAD_ISO03W100")
    (setq pt1 (getpoint "请选择第1点"))
    (princ "\n")
    (setq pt2 (getpoint "请选择第2点"))
    (princ "\n")
    (command "line" pt1 pt2 "")
    (setq o1 (entlast))
    (command "change" o1 "" "p" "la" "zdy1" "")
    (command "celtype" "Continuous")
    (setq dis (getreal "\n输入双线间的距离:"))
    (command "pline" pt1 "w" 30 30 pt2 "")
    (setq o (entlast))

    (command "offset" (/ dis 2) o '(-9999999 -9999999) "")
    (command "change" (entlast) "" "p" "la" "zdy2" "")
    (command "offset" (/ dis 2) o '(9999999 9999999) "")
    (command "change" (entlast) "" "p" "la" "zdy2" "")
    (command "erase" o "")

    (command "scale" o1 "" (middle pt1 pt2) 1.5)
)

(defun middle(pt1 pt2)
    (setq x (/ (+ (car pt1)     (car pt2)) 2))
    (setq y (/ (+ (cadr pt1)    (cadr pt2)) 2))
    (setq z (/ (+ (caddr pt1)   (caddr pt2)) 2))
    (list x y z)
)
回复

使用道具 举报

发表于 2014-8-1 16:22:38 | 显示全部楼层
(command "celtype" "ACAD_ISO03W100") ;;这句是虚线的线型
(command "celtype" "Continuous") ;;;这个是实线的线型
你可以根据自己有的线型做相应修改
回复

使用道具 举报

 楼主| 发表于 2014-8-4 09:47:49 | 显示全部楼层
坏坏的芝麻 发表于 2014-8-1 16:21
我改了一下,试验好使~  你试试吧~

(defun c:bs()

不错,基本达到目的,自己又修改了一下,给分
(defun c:bs()
    (command "undo" "be")
    (command "celtype" "dashed2")
  (if  (=  (tblsearch "layer" "管中心线") nil)
          (command "layer" "m" "管中心线" "c" "2" "" "")
    )
  (if  (=  (tblsearch "layer" "管壁") nil)
          (command "layer" "m" "管壁" "c" "2" "" "")
    )
    (setq pt1 (getpoint "请选择第1点"))
    (princ "\n")
    (setq pt2 (getpoint "请选择第2点"))
    (princ "\n")
    (command "line" pt1 pt2 "")
    (setq o1 (entlast))
    (command "change" o1 "" "p" "la" "管中心线" "")
    (command "celtype" "Continuous")
    (setq dis (getreal "\n输入双线间的距离:"))
    (command "pline" pt1 "w" 30 30 pt2 "")
    (setq o (entlast))

    (command "offset" (/ dis 2) o '(-9999999 -9999999) "")
    (command "change" (entlast) "" "p" "la" "管壁" "")
    (command "offset" (/ dis 2) o '(9999999 9999999) "")
    (command "change" (entlast) "" "p" "la" "管壁" "")
    (command "erase" o "")

    (command "scale" o1 "" (middle pt1 pt2) 1.5)
)

(defun middle(pt1 pt2)
    (setq x (/ (+ (car pt1)     (car pt2)) 2))
    (setq y (/ (+ (cadr pt1)    (cadr pt2)) 2))
    (setq z (/ (+ (caddr pt1)   (caddr pt2)) 2))
    (list x y z)
)
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-18 12:37 , Processed in 0.183943 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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