自动填充的,出错了,帮忙看看!!
<p>Sub test()<br/> Dim hatchObj As AcadHatch<br/> Dim patternName As String<br/> Dim PatternType As Long<br/> Dim bAssociativity As Boolean<br/> Dim outerLoop(0 To 0) As AcadEntity</p><p> ' 定义图案填充<br/> patternName = "ANSI31"<br/> PatternType = 0<br/> bAssociativity = True</p><p> ' 当前图纸的实体数目<br/> Dim n As Long<br/> n = ThisDrawing.ModelSpace.Count<br/> <br/> ' 调用BOUNDARY命令获取某一点处的边界<br/> Dim Pt As Variant<br/> Pt = ThisDrawing.Utility.GetPoint(, "指定内部点: ")<br/> ThisDrawing.SendCommand "_-Boundary" & vbCr & Pt(0) & "," & Pt(1) & vbCr & vbCr<br/> <br/> ' 如果存在边界,则会生成新的实体<br/> Dim lwpLineObj As AcadLWPolyline<br/> If ThisDrawing.ModelSpace.Count > n Then<br/> Set lwpLineObj = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)<br/> MsgBox lwpLineObj.Area<br/>' lwpLineObj.Delete<br/> lwpLineObj.Closed = True<br/> Else<br/> MsgBox "未发现有效的边界。"<br/> End If<br/> outerLoop(0) = lwpLineObj<br/> hatchObj.AppendOuterLoop (outerLoop)<br/> hatchObj.Evaluate<br/> ObjDoc.Regen True<br/>End Sub</p> <p>解决了,</p><p>需要加Boundary命令前加个zoomall命令</p> <p>我想楼主个问题</p><p>在对面域填充时</p><p>当面域为不连续或为环状时则不能正常填充(利用快速选择能选中图案填充,就是不能显示)</p> Dim i As Long<br/>Dim hatchObj As AcadHatch<br/>Dim patternName As String<br/>Dim patternType As Long<br/>Dim assocVar As Boolean<br/>Dim outerLoop(0 To 0) As AcadEntity<br/>Dim eNt As AcadEntity<br/>Dim sset As AcadSelectionSet<br/>Dim outerLoop1(0 To 0) As AcadEntity<br/>Dim n As Long<br/>Dim Pt As Variant<br/>patternName = "SOLID"<br/>patternType = acHatchPatternTypePreDefined<br/>assocVar = True<br/>n = ThisDrawing.ModelSpace.Count<br/>Pt = ThisDrawing.Utility.GetPoint(, "指定内部点: ")<br/>ThisDrawing.SendCommand "_-Boundary" & vbCr & Pt(0) & "," & Pt(1) & vbCr & vbCr<br/>If ThisDrawing.ModelSpace.Count > n Then<br/> Set outerLoop1(0) = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)<br/>Else<br/> MsgBox "未发现有效的边界。"<br/>End If<br/> Set sset = ThisDrawing.SelectionSets.Add("ss7")<br/> sset.AddItems outerLoop1<br/>For Each eNt In sset<br/> Set outerLoop(0) = eNt<br/> Set hatchObj = ThisDrawing.ModelSpace.AddHatch(patternType, patternName, assocVar)<br/> hatchObj.AppendOuterLoop (outerLoop)<br/> hatchObj.Evaluate<br/>Next<br/>sset.Delete<br/>ThisDrawing.Regen True
页:
[1]