明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 666|回复: 14

[提问] 如何用vlisp新建多重引线样式

[复制链接]
发表于 2024-1-16 14:52 | 显示全部楼层 |阅读模式
(vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE")
请问大佬们,用以上函数提取多重引线样式合集后用哪个函数可以在合集里添加一个样式名为“xp”的多重引线样式

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2024-1-16 16:14 | 显示全部楼层
  1. ;;;从AutoCAD 2013 Active Reference帮助中code Examples中提取  
  2. ;;;本源代码由 xshrimp 2013.2.20 搜集整理,版权归原作者所有!  
  3.   
  4.   
  5. (vl-load-com)  
  6. (defun c:Example_MLeaderStyle()  
  7.     (setq acadObj (vlax-get-acad-object))  
  8.     (setq doc (vla-get-ActiveDocument acadObj))  
  9.      
  10.     (setq oDict (vla-Item (vla-get-Dictionaries doc) "ACAD_MLEADERSTYLE")  
  11.           i 0)  
  12.   
  13.     (while (>= (1- (vla-get-Count oDict))  i)  
  14.         (setq oObj (vla-Item oDict i))  
  15.          
  16.         (if (= (vla-get-ObjectName oObj) "AcDbMLeaderStyle")  
  17.             (setq oMLS oObj)  
  18.             
  19.             (alert (strcat "Name = " (vla-get-Name oMLS)  
  20.                            "\nAnnotative = " (if (= (vla-get-Annotative oMLS) :vlax-true) "True" "False")  
  21.                            "\nContentType = " (itoa (vla-get-ContentType oMLS))  
  22.                            "\nLeaderLineType = " (vla-get-Name (vla-get-LeaderLineType oMLS))))  
  23.         )  
  24.          
  25.         (setq i (1+ i))  
  26.     )  
  27.      
  28.     (setq oNewMLS (vla-AddObject oDict "TEST" "AcDbMLeaderStyle"))  
  29.   
  30.     (vla-put-LeaderLineType oNewMLS acSplineLeader)  
  31.   
  32.     (setq oCol (vlax-create-object "AutoCAD.AcCmColor.19"))  
  33.     (vla-put-ColorIndex oCol acBlue)  
  34.     (vla-put-LeaderLineColor oNewMLS oCol)  
  35.   
  36.     (vla-SetVariable doc "CMLEADERSTYLE" "TEST")  
  37.   
  38.     (setq points (vlax-make-safearray vlax-vbDouble '(0 . 5)))  
  39.     (vlax-safearray-fill points '(1 1 0  
  40.                   2 2 0  
  41.                  )  
  42.     )  
  43.     (setq i 0)  
  44.      
  45.     (setq modelSpace (vla-get-ModelSpace doc))  
  46.     (setq oML (vla-AddMLeader modelSpace points i))  
  47.     (vla-put-TextString oML "mleader created with \nstyle "TEST"")  
  48.   
  49.     (vlax-release-object oCol)  
  50. )  
 楼主| 发表于 2024-1-19 13:02 | 显示全部楼层
liuhe 发表于 2024-1-18 17:03
(setq oCol (vlax-create-object "AutoCAD.AcCmColor.19"))  

这个19是对应cad版本,cad2024  就是24  ...

单位的电脑运行(setq NewmleaderstylesObj (vla-AddObject mleaderstylesObj "xp" "AcDbMLeaderStyle"))这行代码时提示错误

; 错误: Automation 错误。 系统注册表中不存在 AcRxClassName 项
发表于 2024-1-18 17:03 | 显示全部楼层
xpzzj 发表于 2024-1-18 14:19
(setq oNewMLS (vla-AddObject oDict "TEST" "AcDbMLeaderStyle"))
大佬,这个函数好像不对吧

(setq oCol (vlax-create-object "AutoCAD.AcCmColor.19"))  

这个19是对应cad版本,cad2024  就是24  我这边测试没问题
 楼主| 发表于 2024-1-16 17:05 | 显示全部楼层
(setq mleaderstylesobj (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE"))
(vla-addobject mleaderstylesobj "xp" "AcDbMLeaderStyle")
用这个函数返回nil
 楼主| 发表于 2024-1-16 17:09 | 显示全部楼层

谢谢,我研究一下
发表于 2024-1-17 13:39 | 显示全部楼层
 楼主| 发表于 2024-1-17 20:54 | 显示全部楼层
天天问 发表于 2024-1-17 13:39
http://bbs.mjtd.com/thread-188328-1-1.html
http://bbs.mjtd.com/thread-185240-1-1.html
多重引线,看 ...

你那个用的是DXF群码,改不了“箭头符号”样式,我想用VLA函数改“箭头符号”样式
 楼主| 发表于 2024-1-18 14:19 | 显示全部楼层

(setq oNewMLS (vla-AddObject oDict "TEST" "AcDbMLeaderStyle"))
大佬,这个函数好像不对吧
 楼主| 发表于 2024-1-18 20:43 | 显示全部楼层
liuhe 发表于 2024-1-18 17:03
(setq oCol (vlax-create-object "AutoCAD.AcCmColor.19"))  

这个19是对应cad版本,cad2024  就是24  ...

奇怪,家里的电脑可以,明天我去单位再看看,谢谢!
 楼主| 发表于 2024-1-18 22:25 | 显示全部楼层
liuhe 发表于 2024-1-18 17:03
(setq oCol (vlax-create-object "AutoCAD.AcCmColor.19"))  

这个19是对应cad版本,cad2024  就是24  ...

(setq oCol (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2))))
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-3 03:44 , Processed in 0.370230 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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