本帖最后由 liuhe 于 2024-4-25 08:44 编辑
- (vl-load-com)
- (defun c:Example_AddHatch()
- ;; This example creates an associative gradient hatch in model space.
- (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 "AutoCAD.AcCmColor.19"))
- (setq col2 (vlax-create-object "AutoCAD.AcCmColor.19"))
- (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))
-
- (setq 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)
-
- (vlax-release-object col1)
- (vlax-release-object col2)
- )
官方例子,用这个方法简单点,只需要自己创建边界就行了,最好用solid填充,因为其他方法填充在求解的时候然后不更新。 |