CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2022 开发者帮助

GradientCentered 属性 (ActiveX)

2024-5-18 18:45| 发布者: admin| 查看: 88| 评论: 0|原作者: admin|来自: AutoCAD

GradientCentered 属性 (ActiveX)

指定渐变是否居中。

支持的平台:仅限 Windows

签名

VBA:

object.GradientCentered
对象

类型:舱口

此属性应用于的对象。

属性值

只读:

类型:布尔

  • True:渐变图案居中。
  • False:渐变图案未居中。

言论

没有其他评论。

例子

VBA:

Sub Example_GradientCentered()
    ' This example changes the value of the GradientCentered property.
    
    Dim hatchObj As AcadHatch
    Dim patternName As String
    Dim PatternType As Long
    Dim bAssociativity As Boolean
    
    ' Define the hatch
    patternName = "CYLINDER"
    PatternType = acPreDefinedGradient '0
    bAssociativity = True
    
    ' Create the associative Hatch object in model space
    Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity, acGradientObject)
    Dim col1 As AcadAcCmColor, col2 As AcadAcCmColor
    Set col1 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." & Left(AcadApplication.Version, 2))
    Set col2 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." & Left(AcadApplication.Version, 2))
    col1.SetRGB 255, 0, 0
    col2.SetRGB 0, 255, 0
    hatchObj.GradientColor1 = col1
    hatchObj.GradientColor2 = col2
    
    ' Create the outer boundary for the hatch (a circle)
    Dim outerLoop(0 To 0) As AcadEntity
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 3: center(1) = 3: center(2) = 0
    radius = 1
    Set outerLoop(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)
    
    ' Append the outerboundary to the hatch object, and display the hatch
    hatchObj.AppendOuterLoop (outerLoop)
    hatchObj.Evaluate
    ThisDrawing.Regen True
    MsgBox "Initial value of GradientCentered is " & hatchObj.GradientCentered
    hatchObj.GradientCentered = False
    MsgBox "New value of GradientCentered is " & hatchObj.GradientCentered
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_GradientCentered()
    ;; This example changes the value of the GradientCentered property.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))    
    
    ;; Define the hatch
    (setq patternName "CYLINDER")
    (setq patternType acPreDefinedGradient)
    (setq bAssociativity :vlax-true)
    
    ;; Create the associative Hatch object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq hatchObj (vla-AddHatch modelSpace patternType patternName bAssociativity acGradientObject))

    (setq col1 (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2))))
    (setq col2 (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2))))
    (vla-SetRGB col1 255 0 0)
    (vla-SetRGB col2 0 255 0)
    (vla-put-GradientColor1 hatchObj col1)
    (vla-put-GradientColor2 hatchObj col2)
    
    ;; Create the outer boundary for the hatch (a circle)
    (setq center (vlax-3d-point 3 3 0)
          radius 1)
    (setq circle (vla-AddCircle modelSpace center radius))

    (setq outerLoop (vlax-make-safearray vlax-vbObject '(0 . 0)))
    (vlax-safearray-put-element outerLoop 0 circle)
    
    ;; Append the outerboundary to the hatch object, and display the hatch
    (vla-AppendOuterLoop hatchObj outerLoop)
    (vla-Evaluate hatchObj)
    (vla-Regen doc :vlax-true)

    (alert (strcat "Initial value of GradientCentered is " (if (= (vla-get-GradientCentered hatchObj) :vlax-true) "True" "False")))
    (vla-put-GradientCentered hatchObj (if (= (vla-get-GradientCentered hatchObj) :vlax-true) :vlax-false :vlax-true))
    (alert (strcat "New value of GradientCentered is " (if (= (vla-get-GradientCentered hatchObj) :vlax-true) "True" "False")))
  
    (vlax-release-object col1)
    (vlax-release-object col2)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 11:42

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部