m333 发表于 2009-5-24 09:51:00

为什么在cad中直接能填充,而vb编程却不行?

<p>最近用vb编程画图发现同样是一个矩形框(全屏幕可见,闭合)用自定义的填充图案在cad 中用填充命令能填充上,而用vb编程却不能填充,小的矩形编程可以填充,一旦矩形上下长度超过某个值就填充不上,用cad自带的“ansi31”没有这种问题,由此判断是自定义填充图案的问题,后面有自定义填充图案,代码如下:</p><p>Private Sub Command1_Click()<br/>Dim point0(3) As Double<br/>Dim point1(3) As Double</p><p>Dim Acadapp As AcadApplication<br/>On Error Resume Next<br/>Set Acadapp = GetObject(, "autocad.application")<br/>If Err Then<br/>&nbsp;&nbsp; Err.Clear<br/>&nbsp;&nbsp; Set Acadapp = CreateObject("autocad.application")<br/>If Err Then<br/>&nbsp;&nbsp; MsgBox ("不能运行AutoCAD")<br/>&nbsp;&nbsp; Exit Sub<br/>&nbsp;&nbsp; End If<br/>End If<br/>Acadapp.WindowState = acMax<br/>Acadapp.Visible = True<br/>Dim a As Single, b As Single<br/>Dim lineobj As AcadLWPolyline<br/>Dim points(0 To 9) As Double<br/>Dim objlist(0) As AcadEntity<br/>Dim objhatch As AcadHatch<br/>a = Val(Text1.Text)&nbsp; '矩形长<br/>b = Val(Text2.Text)&nbsp; '矩形宽,即高,<font color="#ff3300">将该值调高比如&gt;20,即填充不上,这是为什么呢?</font><br/>point0(0) = 0: point0(1) = 0: point0(2) = 0<br/>point1(0) = a: point1(1) = b: point1(2) = 0</p><p>points(0) = 0: points(1) = 0<br/>points(2) = points(0) + a: points(3) = points(1)<br/>points(4) = points(2): points(5) = points(3) + b<br/>points(6) = points(0): points(7) = points(5)<br/>points(8) = 0: points(9) = 0<br/>Set lineobj = Acadapp.ActiveDocument.ModelSpace.AddLightWeightPolyline(points)</p><p>Acadapp.ActiveDocument.ZoomWindow point0, point1<br/>Set objhatch = Acadapp.ActiveDocument.ModelSpace.AddHatch(2, "s200", True, 0)<br/>Set objlist(0) = lineobj<br/>objhatch.AppendOuterLoop (objlist)<br/>objhatch.Evaluate<br/>ThisDrawing.Regen True<br/>End Sub</p><p></p><p>附上自定义的填充图案"s200",这个自定义填充图案有什么问题呢?</p>
页: [1]
查看完整版本: 为什么在cad中直接能填充,而vb编程却不行?