明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 811|回复: 7

[源码] 求助:如何实现对象偏移后变虚线?

[复制链接]
发表于 2023-12-14 23:28 | 显示全部楼层 |阅读模式
本帖最后由 chang1622 于 2023-12-15 11:56 编辑

大侠们,请问如何实现对象(直线 圆,椭圆 多段线等)偏移后变白色虚线?


(defun c:oset()
  (setq obj (car (entsel "\n选择一个对象: ")))
  (setq offsetDist (prompt "\n输入偏移距离: "))
  (setq resultId (acdbObjectIdNew obj offsetDist))
  (setq es (acdbObjectIdOffset obj offsetDist resultId))
  (if (equal es 0)
    (repeat 5
      (setq entityType (cdr (assoc 0 (acdbObjectIdGetAcDbObjectResultType resultId))))
      (if (equal entityType "LINE")
        (progn
          (setq p0 (acdbObjectIdGetPointResult resultId 0))
          (setq p1 (acdbObjectIdGetPointResult resultId 1))
          (command "_.dash" p0 p1)
        )
      )
    )
  )
)


发表于 2023-12-16 10:44 | 显示全部楼层
本帖最后由 lailaifa 于 2023-12-16 10:56 编辑

  • (defun c:tt(/ point pyjl s1 s2)
  •   (setq pyjl (getreal "\n输入偏移距离:"))
  •   (while
  •     (setq s1 (entsel "\n 选择对象:"))
  •     (setq point (getpoint "\n指定偏移方向:"))
  •     (command "OFFSET" pyjl s1 "non" point "")
  •     (setq s2 (entlast))
  •     (command "CHANGE" s2 "" "P" "LT" "HIDDEN" "S" "50" "")
  •   )
  •   (command "REGEN")
  •   (princ)
  • )
回复 支持 1 反对 0

使用道具 举报

发表于 2023-12-15 12:26 | 显示全部楼层
别指望AI 了 全是错误
回复 支持 1 反对 0

使用道具 举报

发表于 2023-12-15 07:05 | 显示全部楼层
偏移成功后,用(setq e (entlast))取得它,然后就可以变虚线了
 楼主| 发表于 2023-12-15 11:56 | 显示全部楼层
自贡黄明儒 发表于 2023-12-15 07:05
偏移成功后,用(setq e (entlast))取得它,然后就可以变虚线了

(defun c:oset()
  (setq obj (car (entsel "\n选择一个对象: ")))
  (setq offsetDist (prompt "\n输入偏移距离: "))
  (setq resultId (acdbObjectIdNew obj offsetDist))
  (setq es (acdbObjectIdOffset obj offsetDist resultId))
  (if (equal es 0)
    (repeat 5
      (setq entityType (cdr (assoc 0 (acdbObjectIdGetAcDbObjectResultType resultId))))
      (if (equal entityType "LINE")
        (progn
          (setq p0 (acdbObjectIdGetPointResult resultId 0))
          (setq p1 (acdbObjectIdGetPointResult resultId 1))
          (command "_.dash" p0 p1)
        )
      )
    )
  )
)
 楼主| 发表于 2023-12-15 11:57 | 显示全部楼层
请问错误的地方
发表于 2023-12-16 11:23 | 显示全部楼层
lailaifa 发表于 2023-12-16 10:44
  • (defun c:tt(/ point pyjl s1 s2)
  •   (setq pyjl (getreal "\n输入偏移距离:"))
  •   (while

  • 大佬好!可以再加上偏移几根线吗?谢谢大佬!
    发表于 2023-12-16 12:32 来自手机 | 显示全部楼层
    榨菜人生 发表于 2023-12-16 11:23
    大佬好!可以再加上偏移几根线吗?谢谢大佬!

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

    本版积分规则

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

    GMT+8, 2024-7-3 08:14 , Processed in 0.161333 second(s), 25 queries , Gzip On.

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

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