明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3962|回复: 14

[提问] 建立多重引线样式,卡在字体颜色那里了

[复制链接]
发表于 2015-4-25 20:56 | 显示全部楼层 |阅读模式
在2014上运行,卡在了文字及线型颜色这里
  1. (SETQ key5 (GETVAR "DIMASZ"))
  2. (if (setq obj (AddMLeaderStyle nam1))
  3.     (progn (vla-put-textstyle obj  "引线");文字样式
  4.            (vla-put-textheight obj 3.5);文字高度
  5.            (vla-put-arrowsize obj key5);箭头大小
  6.            (vla-put-ArrowSymbol obj "_Dot" );箭头符号样式-圆点
  7.           (vla-put-BreakSize obj 0.2);引线打断大小
  8.           (vla-put-ContentType obj acMTextContent);引线类型-acBlockContent=块acMTextContent=多行文字acNoneContent =无
  9.           (vla-put-DrawMLeaderOrderType obj acDrawLeaderTailFirst);acDrawLeaderTailFirst=文字优先acDrawLeaderHeadFirst=基线优先
  10.           (vla-put-FirstSegmentAngleConstraint obj 4);第一段角度60度
  11.           (vla-put-LandingGap obj 0.8);文字附着间隙
  12.           ;(vla-put-LeaderLineColor obj acByLayer);引线颜色(值不正确)
  13.           (vla-put-LeaderLinetype obj 1);引线线型
  14.           (vla-put-LeaderLineWeight obj -1);引线宽度
  15.           (vla-put-LeaderLineTypeId obj "ByLayer");引线类型iD
  16.           (vla-put-MaxLeaderSegmentsPoints obj 2);最大引线点数
  17.           ;(vla-put-OverwritePropChanged obj False);覆盖特性值True,False(说没这个参数)
  18.           (vla-put-SecondSegmentAngleConstraint Property obj 6);第二段角度90度
  19.           (vla-put-TextAlignmentType obj 0);文字对齐类型acCenterAlignment=中acLeftAlignment=左acRightAlignment=右
  20.           (vla-put-TextAngleType obj 1);文字角度(这个值应该设置什么?)
  21.           (vla-put-TextAttachmentDirection obj 0);文字附着方向acAttachmentHorizontal=水平acAttachmentVertical=垂直
  22.           (vla-put-TextBottomAttachmentType obj 0);底部文字附着方向acAttachmentCenter=居中acAttachmentLinedCenter=下划线并居中
  23.           ;(vla-put-TextColor obj acYellow);文字颜色(值不正确,但查询应该是这个值,不知为什么)
  24.           (vla-put-TextLeftAttachmentType obj 7);左对齐位置文字连接位置类型
  25.           (vla-put-TextRightAttachmentType obj 7);右对齐位置文字连接位置类型
  26.           (vla-put-TextTopAttachmentType obj 0);顶部文字附着方向acAttachmentCenter=居中acAttachmentLinedCenter=下划线并居中
  27.           (vla-put-ScaleFactor obj scal)
  28.           (setvar "CMLEADERSTYLE" nam1)
  29.     )
  30.   )
通过设置了样式后,使用(vlax-dump-object (vla-item (vla-item (vlax-ename->vla-object (namedobjdict))  "ACAD_MLEADERSTYLE") "standard") t)
获取了特征码,如下:
; IAcadMLeaderStyle: AutoCAD 多重引线样式界面
;特性值:
;   AlignSpace = 4.0
;   Annotative = 0
;   Application (RO) = #<VLA-OBJECT IAcadApplication 000000013fcfc910>
;   ArrowSize = 1.0
;   ArrowSymbol = "_Dot"
;   BitFlags = 0
;   Block = ""
;   BlockColor = #<VLA-OBJECT IAcadAcCmColor 000000002c9fb3f0>
;   BlockConnectionType = 0
;   BlockRotation = 0.0
;   BlockScale = 1.0
;   BreakSize = 0.125
;   ContentType = 2
;   Description = "Standard"
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000002c69af88>
;   DoglegLength = 2.0
;   DrawLeaderOrderType = 0
;   DrawMLeaderOrderType = 1
;   EnableBlockRotation = -1
;   EnableBlockScale = -1
;   EnableDogleg = -1
;   EnableFrameText = 0
;   EnableLanding = -1
;   FirstSegmentAngleConstraint = 4
;   Handle (RO) = "131"
;   HasExtensionDictionary (RO) = 0
;   LandingGap = 0.8
;   LeaderLineColor = #<VLA-OBJECT IAcadAcCmColor 000000002c9fab50>
;   LeaderLinetype = 1
;   LeaderLineTypeId = "ByLayer"
;   LeaderLineWeight = -1
;   MaxLeaderSegmentsPoints = 2
;   Name = "Standard"
;   ObjectID (RO) = 43
;   ObjectID32 (RO) = 43
;   ObjectName (RO) = "AcDbMLeaderStyle"
;   OverwritePropChanged (RO) = -1
;   OwnerID (RO) = 44
;   OwnerID32 (RO) = 44
;   ScaleFactor = 20.0
;   SecondSegmentAngleConstraint = 6
;   TextAlignmentType = 0
;   TextAngleType = 1
;   TextAttachmentDirection = 0
;   TextBottomAttachmentType = 0
;   TextColor = #<VLA-OBJECT IAcadAcCmColor 000000002c9fb090>
;   TextHeight = 4.0
;   TextLeftAttachmentType = 7
;   TextRightAttachmentType = 7
;   TextString = ""
;   TextStyle = "Standard"
;   TextTopAttachmentType = 0
;支持的方法:
;   Delete ()
;   GetExtensionDictionary ()
;   GetXData (3)
;   SetXData (2)

其余的参数值能直接填写,但这个TextColor = #<VLA-OBJECT IAcadAcCmColor 000000002c9fb090>,不知道怎样使用,我需要字体颜色是2号色
发表于 2024-3-23 15:32 | 显示全部楼层
(progn
        (if (not (setq col_num (acad_colordlg 256 )))(setq col_num 256))
        (setq xobj (vlax-ename->vla-object (car(entsel))))
        (setq mlstyle  (vla-item (vla-item (vlax-ename->vla-object (namedobjdict))  "ACAD_MLEADERSTYLE") "Mls_Mtxt"))  ;样式名自已改
        (setq oCol (vlax-create-object (strcat "autocad.accmcolor." (substr (getvar 'acadver) 1 2))))
        (vla-put-ColorIndex oCol 256)
        (vla-put-textcolor mlstyle oCol)   ;多线的字体颜色随层,用于后面的vla-put-Color来修改
        (vla-put-ColorIndex oCol col_num)
        (vla-put-LeaderLineColor xobj oCol) ;引线的颜色
        (vla-put-Color xobj col_num)
)

本帖子中包含更多资源

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

x
发表于 2019-6-17 21:58 | 显示全部楼层
yfywk 发表于 2015-4-27 16:45
setq color (vla-GetInte**ceObject (vlax-get-acad-object) "AutoCAD.AcCmColor.19"));我在2014上用就写19 ...

  1. (setq oCol (vlax-create-object (strcat "autocad.accmcolor." (substr (getvar 'acadver) 1 2))))  ;:vlax-true
  2.         (vla-put-ColorIndex oCol acGreen)
  3.         (vla-put-LeaderLineColor oNewMLS oCol)

这样子就不用管版本号了
发表于 2021-1-5 16:59 | 显示全部楼层
感谢前面楼主提供的源码,经实践总结如下:
①MLeader样式建立时,要注意把文字颜色设成256,即随层
相关思路是把引线颜色和文字颜色分开
②用前面楼主的 vla-put-LeaderLineColor更改引线颜色(注意颜色值要转换)。
③用vla-put-Color更改文字颜色(注意颜色值直接用0-256即可)
发表于 2015-4-25 21:56 | 显示全部楼层
先谢谢你回答了我的问题
你的问题,建议你可以参考一下单行文字或多行文的字体颜色,应该是一样的吧
发表于 2015-4-26 08:37 | 显示全部楼层
祝楼主研究成功
 楼主| 发表于 2015-4-27 16:45 | 显示全部楼层
setq color (vla-GetInte**ceObject (vlax-get-acad-object) "AutoCAD.AcCmColor.19"));我在2014上用就写19
(vla-setrgb color 255 255 0)
(vla-put-colorindex color 2)
(vla-put-TextColor mlstyle color);最下面的这一行改成这样就行了
发表于 2015-4-28 14:01 | 显示全部楼层
学习一下
发表于 2018-1-11 09:39 | 显示全部楼层
颜色问题我试过0-256,256随层,0随块.其他即为索引颜色
发表于 2018-1-11 09:40 | 显示全部楼层
为什呢我的电脑提示错误: no function definition: ADDMLEADERSTYLE
发表于 2019-10-5 08:51 | 显示全部楼层
发表于 2020-10-19 16:49 | 显示全部楼层
我就想知道是不是没有办法通过程序将某个多重引线样式置为当前
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-25 20:30 , Processed in 0.203838 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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