- UID
- 268522
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-5-29
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Dim hatchObj As AcadHatch '定义填充对象变量
Dim patternName As String '定义图案填充名称
Dim PatternType As Long '定义图案填充类型
Dim bAssociativity As Boolean '定义图案填充与边界是否关联的布尔变量
PatternType = acHatchPatternTypeCustomDefined '使填充类型为自定义的图案填充,在此如果换成acHatchPatternTypepredefined,把下面的b056换成ANSI31,程序则不出错
patternName = "b056" '填充文件名为b056.pat的自定义图案填充文件
bAssociativity = true '关联边界
Set hatchObj = acadapp.ActiveDocument.ModelSpace.AddHatch(PatternType, patternName, bAssociativity)
'创建填充对象
Dim outerLoop(0 To 3) As AcadEntity
Dim innerloop(0 To 3) As AcadEntity
Dim startpoint1(0 To 2) As Double
Dim endpoint1(0 To 2) As Double
Dim startpoint2(0 To 2) As Double
Dim endpoint2(0 To 2) As Double
Dim startpoint3(0 To 2) As Double
Dim endpoint3(0 To 2) As Double
Dim startpoint4(0 To 2) As Double
Dim endpoint4(0 To 2) As Double
Dim pa As Double
startpoint1(0) = -50#: startpoint1(1) = -50#: startpoint1(2) = 0#
endpoint1(0) = 50#: endpoint1(1) = -50#: endpoint1(2) = 0#
startpoint2(0) = 50#: startpoint2(1) = -50#: startpoint2(2) = 0#
endpoint2(0) = 50#: endpoint2(1) = 50#: endpoint2(2) = 0#
startpoint3(0) = 50#: startpoint3(1) = 50#: startpoint3(2) = 0#
endpoint3(0) = -50#: endpoint3(1) = 50#: endpoint3(2) = 0#
startpoint4(0) = -50#: startpoint4(1) = 50#: startpoint4(2) = 0#
endpoint4(0) = -50#: endpoint4(1) = -50#: endpoint4(2) = 0#
'为填充边界四边形定义数组及为其赋值
Set outerLoop(0) = acadapp.ActiveDocument.ModelSpace.AddLine(startpoint1, endpoint1)
Set outerLoop(1) = acadapp.ActiveDocument.ModelSpace.AddLine(startpoint2, endpoint2)
Set outerLoop(2) = acadapp.ActiveDocument.ModelSpace.AddLine(startpoint3, endpoint3)
Set outerLoop(3) = acadapp.ActiveDocument.ModelSpace.AddLine(startpoint4, endpoint4)
'创建填充边界四边形
hatchObj.AppendOuterLoop (outerLoop)
'用自定义库为四边形填充
hatchObj.Evaluate
'用Evaluate方法进行求值,程序在此出错
acadapp.ActiveDocument.Regen acActiveViewport
acadapp.ActiveDocument.SaveAs "c:\wxy.dwg"
acadapp.Application.Visible = True
ZoomExtents
'显示图形 |
|