9701519 发表于 2024-11-4 12:49:00

如何不炸开块情况下修改改块内线形改为随块,线形比例改为100?(已经解决))

本帖最后由 9701519 于 2024-11-4 18:34 编辑

如何不炸开块情况下修改改块内线形改为随块,线形比例改为100?

(Defun c:tt (/ BLK)
(and
    (setq blk (car (entsel "\n Pick Block <exit>:")))
    (setq blk (vlax-ename->vla-object blk))
    (vlax-property-available-p blk "effectivename")
    (= (vlax-for vlo
   (vla-item
       (vla-get-blocks
         (vla-get-activeDocument (vlax-get-acad-object))
       )
       (vla-get-effectivename blk)
   )
   (vla-put-Linetype vlo "ByBlock")
   (vla-put-LinetypeScale vlo 100.)
   (vla-put-Lineweight vlo acLnWtByBlock)
   (vla-put-Color vlo 0)
   (vla-put-Layer vlo "0")
       )
       (vla-update blk)
    )
)
)

kozmosovia 发表于 2024-11-4 14:04:22

本帖最后由 kozmosovia 于 2024-11-4 14:08 编辑

代码搞复杂了

(Defun c:tt (/ BLK)
(and
    (setq blk (car (entsel "\n Pick Block <exit>:")))
    (setq blk (vlax-ename->vla-object blk))
    (vlax-property-available-p blk "effectivename")
    (= (vlax-for vlo
   (vla-item
       (vla-get-blocks
         (vla-get-activeDocument (vlax-get-acad-object))
       )
       (vla-get-effectivename blk)
   )
   (vla-put-Linetype vlo "ByBlock")
   (vla-put-LinetypeScale vlo 100.)
   (vla-put-Lineweight vlo "byblock")
   (vla-put-Color vlo 0)
   (vla-put-Layer vlo "0")
       )
       (vla-update blk)
    )
)
)

llsheng_73 发表于 2024-11-4 13:35:39

(DEFUN C:TT(/ e *BLCOKS e);;修改所有块内所有对象线型为随块、线型比例100
(vl-load-com)
(setq *blocks(vlax-get-property(vlax-get-property(vlax-get-acad-object)'activedocument)'blocks))
(while(setq e(TblNext "BLOCK"(not e)))
    (tt(cdadr e)"byblock" 100))
)

(defun tt(blkname ltpname ltpscale / blk o i);;修改指定块名内所有对象线型、线型比例
(setq blk(vlax-invoke-method *blocks 'item blkname)
        i -1)
(repeat(vlax-get-property blk 'count)
    (setq i(1+ i)o(vlax-invoke-method blk 'item i))
    (vlax-put-property o 'Linetype ltpname)
    (vlax-put-property o 'LinetypeScale ltpscale)))

9701519 发表于 2024-11-4 13:09:21

kozmosovia 发表于 2024-11-4 12:50
遍历块定义改

在不炸开块的情况下实现以下功能(defun C:tt( )
    (setq se1(ssget))
   (vl-cmdf "_change" "si" se1 "p" "lt" "byblock" "")
   (vl-cmdf "_change" "si" se1 "p" "s" "1" "")
   (vl-cmdf "_chprop" se1 "" "la" "0" "C" "byblock" "LW" "byblock" "")
)

kozmosovia 发表于 2024-11-4 12:50:39

遍历块定义改

9701519 发表于 2024-11-4 14:09:02

llsheng_73 发表于 2024-11-4 13:35


如何再加上以下功能:
1.框选选择需要修改的块
2.全部改0层,
3.颜色随块,
4.线宽随块,

9701519 发表于 2024-11-4 14:23:17

kozmosovia 发表于 2024-11-4 14:04
代码搞复杂了

命令执行有点问题:
Pick Block <exit>:; 错误: 此类型的 LISP 值不能强制转换成 VARIANT:"byblock"

panliang9 发表于 2024-11-4 14:42:32

看这个。
http://bbs.mjtd.com/thread-59143-1-1.html

9701519 发表于 2024-11-4 15:37:16

panliang9 发表于 2024-11-4 14:42
看这个。
http://bbs.mjtd.com/thread-59143-1-1.html

为什么块会变大

panliang9 发表于 2024-11-4 15:50:09

改线型比例用这个:
http://bbs.mjtd.com/thread-186469-1-1.html

还有发例图才知道为什么块会变大。
页: [1] 2
查看完整版本: 如何不炸开块情况下修改改块内线形改为随块,线形比例改为100?(已经解决))