求高手指点,若有交点,交点坐标写入数组,若无则不写入
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"></meta><meta content="Word.Document" name="ProgId"></meta><meta content="Microsoft Word 11" name="Generator"></meta><meta content="Microsoft Word 11" name="Originator"></meta><link href="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List"></link><!--Element not supported - Type: 8 Name: #comment--><!--Element not supported - Type: 8 Name: #comment--><style><!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style><!--Element not supported - Type: 8 Name: #comment-->
<p class="MsoNormal">For Each ent In ThisDrawing.ModelSpace<op></op></p>
<p class="MsoNormal"><span>
intPoints = vbEmpty<op></op></span></p>
<p class="MsoNormal"><span>
intPoints = lineObj.IntersectWith(ent, acExtendNone)<op></op></span></p>
<p class="MsoNormal"><span> If VarType(intPoints) <> vbEmpty Then<op></op></span></p>
<p class="MsoNormal"><span>
ReDim Preserve px(I) As Variant<op></op></span></p>
<p class="MsoNormal"><span>
ReDim Preserve py(I) As Variant<op></op></span></p>
<p class="MsoNormal"><span>
ReDim Preserve pz(I) As Variant<op></op></span></p>
<p class="MsoNormal"><span>
</span></p>
<p class="MsoNormal" style="text-indent: 31.5pt;">px(I) = intPoints(0)<op></op></p>
<p class="MsoNormal"><span>
py(I) = intPoints(1)<op></op></span></p>
<p class="MsoNormal"><span>
pz(I) = intPoints(2)<op></op></span></p>
<p class="MsoNormal"><span> <op></op></span></p>
<p class="MsoNormal"><span>
MsgBox px(I) & py(I) & pz(I)<op></op></span></p>
<p class="MsoNormal"><span>
End If<op></op></span></p>
<p class="MsoNormal">Next ent<op></op></p> 看不懂你的,我写了一个
Sub test()
On Error Resume Next
Dim obj1 As AcadEntity
Dim pt As Variant
ThisDrawing.Utility.GetEntity obj1, pt
Dim bpts(0 To 11) As Double
Dim minpt As Variant
Dim maxpt As Variant
obj1.GetBoundingBox minpt, maxpt
bpts(0) = minpt(0)
bpts(1) = minpt(1)
bpts(2) = minpt(2)
bpts(3) = minpt(0)
bpts(4) = maxpt(1)
bpts(5) = minpt(2)
bpts(6) = maxpt(0)
bpts(7) = maxpt(1)
bpts(8) = maxpt(2)
bpts(9) = maxpt(0)
bpts(10) = minpt(1)
bpts(11) = maxpt(2)
Dim ss As AcadSelectionSet
ThisDrawing.SelectionSets.Add ("test")
Set ss = ThisDrawing.SelectionSets.Item("test")
ss.SelectByPolygon acSelectionSetCrossingPolygon, bpts
For Each obj In ss
If Not (obj Is obj1) Then
'MsgBox "OK"
'Else
Dim ipts As Variant
ipts = obj1.IntersectWith(obj, acExtendNone)
MsgBox "有" & (UBound(ipts) + 1) / 3 & "个交点"
End If
Next
End Sub
我想获取模型空间中指定直线的交点,但是判断语句不对,执行时不管与指定直线有没有交点,i值总是加1<br/>如何判断有交点时i加1,没有时i值不变?<br/> <font face="Verdana" color="#61b713"><b>刚才运行了sailorcwx的代码,感觉判断语句有问题,结果上传如图。</b></font>
页:
[1]