Tipo166 发表于 2022-7-6 14:14:35

图案填充区域对象-多重

大家好,
我需要用多个区域填充一个区域:
https://www.cadtutor.net/forum/attachment.php?attachmentid=8797&stc=1&d=1229121988
 
尝试修改示例代码:

Public Function AddHatch(Region As AcadRegion) As AcadHatch
   ' This example creates an associative gradient hatch in model space.
   Dim patternName As String
   Dim PatternType As Long
   Dim bAssociativity As Boolean
   Dim outerLoop() As AcadEntity
   ReDim outerLoop(0)
   Dim oplineReg As AcadEntity
   Set oplineReg = Region.Copy
   Set outerLoop(0) = Region
   ' 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.17")
   Set col2 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.17")
   Call col1.SetRGB(255, 0, 0)
   Call col2.SetRGB(0, 255, 0)
   hatchObj.GradientColor1 = col1
   hatchObj.GradientColor2 = col2
   
   ' Append the outerboundary to the hatch object, and display the hatch
   hatchObj.AppendOuterLoop outerLoop
   hatchObj.Evaluate
   ThisDrawing.Regen True
End Function

 
此处输入无效:
hatchObj。附录outerLoop outerLoop
 
显然没有“OuterLoop”,但使用std autocad hatch命令及其选项填充对象非常简单。有什么想法吗?
 
谢谢
特伦特

rmorton@gocfi.c 发表于 2022-7-6 14:58:17

我似乎也有同样的问题

mtrasi 发表于 2022-7-6 15:19:18

你试过了吗
Dim outerLoop(0)作为AcadEntity
 
而不是
Dim outerLoop()作为AcadEntity
ReDim outerLoop(0)
 
有时vba从变体错误到其他类型。。。
你对每个地区都有这个问题吗?还是只有其中的一部分?
对我来说,这种方法:附加循环求值,总是处理闭合对象(并且一个区域是闭合的)
页: [1]
查看完整版本: 图案填充区域对象-多重