乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 138|回复: 6

Addhatch有多个AppendInnerLoop

[复制链接]

12

主题

38

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
86
发表于 2015-6-5 23:23:00 | 显示全部楼层 |阅读模式
Addhatch有多个AppendInnerLoop时运行出错,提示“输入无效” ,请问应如何修改?我试了把下面改成 inloop(0 to 0)只使用一个内部的inloop就可以运行,确认了图形没有错,item(1)和item(2)是在 item(0)的内部,并封闭。
Sub kk()
Dim pname As String
Dim hatchobj As AcadHatch
Dim ba As Boolean
Dim pat As Long
Dim outloop(0 To 0) As AcadEntity
Dim inloop(0 To 1) As AcadEntity
pat = 0
pname = "ANSI31"
ba = True
Set outloop(0) = ThisDrawing.ModelSpace.Item(0)
Set inloop(0) = ThisDrawing.ModelSpace.Item(1)
Set inloop(1) = ThisDrawing.ModelSpace.Item(2)
Set hatchobj = ThisDrawing.ModelSpace.AddHatch(pat, pname, ba)
hatchobj.AppendOuterLoop (outloop)
hatchobj.AppendInnerLoop (inloop)
hatchobj.Evaluate
ThisDrawing.Regen True
End Sub
回复

使用道具 举报

12

主题

38

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
86
发表于 2015-6-6 11:24:00 | 显示全部楼层
没人会吗?我就想知道,如果有两个inloop时,怎么改?
回复

使用道具 举报

23

主题

561

帖子

13

银币

中流砥柱

Rank: 25

铜币
653
发表于 2015-6-6 15:48:00 | 显示全部楼层
inloop如果使用多于一个对象,它们的端点必须相接以形成一个环。
回复

使用道具 举报

23

主题

561

帖子

13

银币

中流砥柱

Rank: 25

铜币
653
发表于 2015-6-6 15:50:00 | 显示全部楼层
Sub Example_AppendInnerLoop()
    ' This example creates an associative hatch in model space.
   
    Dim hatchObj As AcadHatch
    Dim patternName As String
    Dim PatternType As Long
    Dim bAssociativity As Boolean
   
    ' Define the hatch
    patternName = "Solid"
    PatternType = 0
    bAssociativity = True
   
    ' Create the associative Hatch object
    Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity)
   
    ' Create the outer loop for the hatch.
    ' An arc and a line are used to create a closed loop.
   
    Dim outerLoop(0 To 1) As AcadEntity
    Dim center(0 To 2) As Double
    Dim radius As Double
    Dim startAngle As Double
    Dim endAngle As Double
    center(0) = 5: center(1) = 3: center(2) = 0
    radius = 3
    startAngle = 0
    endAngle = 3.141592
    Set outerLoop(0) = ThisDrawing.ModelSpace.AddArc(center, radius, startAngle, endAngle)
    Set outerLoop(1) = ThisDrawing.ModelSpace.AddLine(outerLoop(0).StartPoint, outerLoop(0).EndPoint)
        
    ' Append the outer loop to the hatch object
    hatchObj.AppendOuterLoop (outerLoop)
   
    ' Append a circle as the inner loop for the hatch.
    Dim innerLoop(1) As AcadEntity
    center(0) = 5: center(1) = 4.5: center(2) = 0
    radius = 1
    Set innerLoop(0) = ThisDrawing.ModelSpace.AddArc(center, radius, startAngle, endAngle)
    Set innerLoop(1) = ThisDrawing.ModelSpace.AddLine(innerLoop(0).StartPoint, innerLoop(0).EndPoint)
    hatchObj.AppendInnerLoop (innerLoop)
   
    ' Evaluate and display the hatch
    hatchObj.Evaluate
    ThisDrawing.Regen True
   
End Sub
回复

使用道具 举报

12

主题

38

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
86
发表于 2015-6-6 15:53:00 | 显示全部楼层

如果是分开的两个独立图形怎么办?有没有其他办法?我的图形就相当于一个脸上(圆),有两眼睛(里面两个眼),还有嘴巴(三角形),鼻子(小矩形)等。
回复

使用道具 举报

23

主题

561

帖子

13

银币

中流砥柱

Rank: 25

铜币
653
发表于 2015-6-6 16:09:00 | 显示全部楼层

Option Explicit
Sub Example_AppendInnerLoop()
    ' This example creates an associative hatch in model space.
   
    Dim hatchObj As AcadHatch
    Dim patternName As String
    Dim PatternType As Long
    Dim bAssociativity As Boolean
   
    ' Define the hatch
    patternName = "Solid"
    PatternType = 0
    bAssociativity = True
   
    ' Create the associative Hatch object
    Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity)
   
    ' Create the outer loop for the hatch.
    ' An arc and a line are used to create a closed loop.
   
    Dim outerLoop(0 To 1) As AcadEntity
    Dim center(0 To 2) As Double
    Dim radius As Double
    Dim startAngle As Double
    Dim endAngle As Double
    center(0) = 5: center(1) = 3: center(2) = 0
    radius = 3
    startAngle = 0
    endAngle = 3.141592
    Set outerLoop(0) = ThisDrawing.ModelSpace.AddArc(center, radius, startAngle, endAngle)
    Set outerLoop(1) = ThisDrawing.ModelSpace.AddLine(outerLoop(0).StartPoint, outerLoop(0).EndPoint)
        
    ' Append the outer loop to the hatch object
    hatchObj.AppendOuterLoop (outerLoop)
   
    ' Append a circle as the inner loop for the hatch.
    Dim innerLoop(1) As AcadEntity
    center(0) = 5: center(1) = 4.5: center(2) = 0
    radius = 1
    Set innerLoop(0) = ThisDrawing.ModelSpace.AddArc(center, radius, startAngle, endAngle)
    Set innerLoop(1) = ThisDrawing.ModelSpace.AddLine(innerLoop(0).StartPoint, innerLoop(0).EndPoint)
    hatchObj.AppendInnerLoop (innerLoop)
   
    Dim innerLoop2(1) As AcadEntity
    center(0) = 3.3: center(1) = 3.3: center(2) = 0
    radius = 1
    Set innerLoop2(0) = ThisDrawing.ModelSpace.AddArc(center, radius, startAngle, endAngle)
    Set innerLoop2(1) = ThisDrawing.ModelSpace.AddLine(innerLoop2(0).StartPoint, innerLoop2(0).EndPoint)
    hatchObj.AppendInnerLoop (innerLoop2)
   
    ' Evaluate and display the hatch
    hatchObj.Evaluate
    ThisDrawing.Regen True
   
End Sub
回复

使用道具 举报

12

主题

38

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
86
发表于 2015-6-6 17:22:00 | 显示全部楼层

明白了,感谢老大,原来一个inner要appendinnerloop一遍呀。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-4-20 15:14 , Processed in 2.462488 second(s), 67 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表