明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1281|回复: 1

[求助]怎样创建填充图形

[复制链接]
发表于 2009-1-12 16:30:00 | 显示全部楼层 |阅读模式
各位大侠 :

  在ATUOLISP中用(command "solid" in_pk31 in_pk30 in_pk32 in_pk31 \)命令可以创建一个

三角填充图。

VBA中怎样实现此功能?

我用下面的命令,系统提示输入点无效

ThisDrawing.SendCommand "solid" & vbCr & "pick_point_first(0)" & vbCr & "point_arrow(0)" & vbCr & "point_arrow(1)" & vbCr & "pick_point_first(0)" & vbCr

谢谢各位大侠帮忙

发表于 2009-1-14 12:54:00 | 显示全部楼层

CAD帮助文件中有这样的代码,稍做修改便可以满足要求:

Sub Example_AddHatch()
    ' This example creates an associative gradient hatch in model space.
   
    Dim hatchObj As AcadHatch
    Dim patternName As String
    Dim PatternType As Long
    Dim bAssociativity As Boolean
   
  
    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.16")
    Set col2 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")
    Call col1.SetRGB(255, 0, 0)
    Call 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
End Sub

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 04:36 , Processed in 0.162507 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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