指定对象或图层的颜色。 支持的平台:仅窗口 签名工 务 局: object.Color
属性值只读:否(只写对象除外)Group 类型:枚举acColor 默认颜色指定为。使用介于 0 到 256 之间的颜色索引号,或此处列出的常量之一:acByLayer
言论此属性对于大多数图形对象都是过时的,将在将来的版本中相应地删除。使用此属性时,可以将颜色设置为介于 0 到 256 之间的数字索引值并将其读取。为标准的七种颜色以及 BYBLOCK 和 BYLAYER 名称提供了常量。 如果使用,AutoCAD 将以默认颜色(白色或黑色,具体取决于您的配置)绘制新对象,直到它们被分组到块中。在图形中插入块时,块中的对象将继承颜色属性的当前设置。acByBlock 如果使用,新对象将采用绘制它们的图层的颜色。该值对对象无效。acByLayeracByLayerLayer 例子工 务 局: Sub Example_Color() ' This example creates a polyline and colors it red. ' It then displays the current color setting for the polyline. Dim plineObj As AcadPolyline Dim currentcolor As Variant ' Create Polyline Dim points(8) As Double points(0) = 3: points(1) = 7: points(2) = 0 points(3) = 9: points(4) = 2: points(5) = 0 points(6) = 3: points(7) = 5: points(8) = 0 Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points) ' First set the color of the object to Red plineObj.Color = acRed ThisDrawing.Regen (True) ' Now retrieve and display the Color property currentcolor = plineObj.Color ' Translate the color from a number into text If currentcolor = 256 Then currentcolor = "By Layer" Else currentcolor = Choose(currentcolor + 1, "By Block", "Red", "Yellow", "Green", "Cyan", "Blue", "Magenta", "White") End If ' Display MsgBox "The Polyline color is: " & currentcolor, vbInformation, "Color Example" End Sub Visual LISP: (vl-load-com) (defun c:Example_Color() ;; This example creates a polyline and colors it red. ;; It then displays the current color setting for the polyline. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Create Polyline (setq points (vlax-make-safearray vlax-vbDouble '(0 . 8))) (vlax-safearray-fill points '(3 7 0 9 2 0 3 5 0 ) ) (setq modelSpace (vla-get-ModelSpace doc)) (setq plineObj (vla-AddPolyline modelSpace points)) ;; First set the color of the object to Red (vla-put-Color plineObj acRed) (vla-Regen doc :vlax-true) ;; Now retrieve and display the Color property (setq currentcolor (vla-get-Color plineObj)) ;; Translate the color from a number into text (if (= currentcolor 256) (setq currentcolor "ByLayer") (setq currentcolor (cond ((= currentcolor 257) "ByBlock") ((= currentcolor 1) "Red") ((= currentcolor 2) "Yellow") ((= currentcolor 3) "Green") ((= currentcolor 4) "Cyan") ((= currentcolor 5) "Blue") ((= currentcolor 6) "Magenta") ((= currentcolor 7) "White/Black") ("Other") )) ) ;; Display (alert (strcat "The Polyline color is: " currentcolor)) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:30
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.