CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

颜色方法属性 (ActiveX)

2023-1-3 20:28| 发布者: admin| 查看: 556| 评论: 0|来自: AutoCAD

摘要: 指定颜色方法。

指定颜色方法。

支持的平台:仅窗口

签名

工 务 局:

object.ColorMethod
对象

类型:AcCm颜色

此属性适用的对象。

属性值

只读:

类型:枚举acColorMethod

默认颜色方法是。若要直接确定颜色的设置方式,请使用此处列出的常量:acColorMethodByLayer

  • acColorMethodByACI
  • acColorMethodByBlock
  • acColorMethodByLayer
  • acColorMethodByRGB
  • acColorMethodForeground

言论

没有额外的评论。

例子

工 务 局:

Sub Example_ColorMethod()
    ' This example shows how to change the
    ' ColorMethod property
    Dim col As AcadAcCmColor
    Set col = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." & Left(AcadApplication.Version, 2))
    col.ColorMethod = AutoCAD.acColorMethodForeground
            
    ' Circle number one
    Dim cir1 As AcadCircle
    Dim pt(0 To 2) As Double
    Set cir1 = ThisDrawing.modelSpace.AddCircle(pt, 2)
    cir1.TrueColor = col
    ZoomAll
        
    Dim retCol As AcadAcCmColor
    Set retCol = cir1.TrueColor
        
    ' Message box with method and index
    Dim MethodText As String
    MethodText = col.ColorMethod
    MsgBox "ColorMethod=" & MethodText & vbCrLf & "Index=" & col.ColorIndex
        
    ' Circle number two
    Dim cir2 As AcadCircle
    Set cir2 = ThisDrawing.modelSpace.AddCircle(pt, 6)
    ZoomAll
       
    col.ColorMethod = AutoCAD.acColorMethodByBlock
       
    ' Message box with method and index
    MethodText = col.ColorMethod
    MsgBox "ColorMethod=" & MethodText & vbCrLf & "Index=" & col.ColorIndex
       
    ' Circle number three
    Dim cir3 As AcadCircle
    Set cir3 = ThisDrawing.modelSpace.AddCircle(pt, 10)
    ZoomAll
    
    Dim layColor As AcadAcCmColor
    Set layColor = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." & Left(AcadApplication.Version, 2))
    layColor.SetRGB 122, 199, 25
    ThisDrawing.ActiveLayer.TrueColor = layColor
        
    col.ColorMethod = AutoCAD.acColorMethodByLayer
      
    Set retCol = cir3.TrueColor
                
    ' Message box with method and index
    MethodText = col.ColorMethod
    MsgBox "ColorMethod=" & MethodText & vbCrLf & "Index=" & col.ColorIndex
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_ColorMethod()
    ;; This example shows how to change the
    ;; ColorMethod property
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq modelSpace (vla-get-ModelSpace doc))  
  
    (setq col (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2))))
    (vla-put-ColorMethod col acColorMethodForeground)
            
    ;; Circle number one
    (setq pt (vlax-3d-point 0 0 0))

    (setq cir1 (vla-AddCircle modelSpace pt 2))
    (vla-put-TrueColor cir1 col)
    (vla-ZoomAll acadObj)
    (vla-Regen doc :vlax-true)
        
    (setq retCol (vla-get-TrueColor cir1))
        
    ;; Message box with method and index
    (setq MethodText (vla-get-ColorMethod col))
    (alert (strcat "ColorMethod=" (itoa MethodText) "\nIndex=" (itoa (vla-get-ColorIndex col))))
        
    ;; Circle number two
    (setq cir2 (vla-AddCircle modelSpace pt 6))
    (vla-ZoomAll acadObj)
    (vla-Regen doc :vlax-true)
  
    (vla-put-ColorMethod col acColorMethodByBlock)
       
    ;; Message box with method and index
    (setq MethodText (vla-get-ColorMethod col))
    (alert (strcat "ColorMethod=" (itoa MethodText) "\nIndex=" (itoa (vla-get-ColorIndex col))))
        
    ;; Circle number three
    (setq cir3 (vla-AddCircle modelSpace pt 10))
    (vla-ZoomAll acadObj)
    (vla-Regen doc :vlax-true)
    
    (setq layColor (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2))))
    (vla-SetRGB layColor 122 199 25)
    (vla-put-TrueColor (vla-get-ActiveLayer doc) layColor)
        
    (vla-put-ColorMethod col acColorMethodByLayer)
      
    (setq retCol (vla-get-TrueColor cir3))
    (vla-Regen doc :vlax-true)
                
    ;;Message box with method and index
    (setq MethodText (vla-get-ColorMethod col))
    (alert (strcat "ColorMethod=" (itoa MethodText) "\nIndex=" (itoa (vla-get-ColorIndex col))))

    (vlax-release-object col)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 11:48

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部