happy72096 发表于 2009-6-15 17:39:00

[求助]请问有没有求任意两个对象交点的程序

如题,请问有没有求任意两个对象交点的程序,不胜感激

nzl1116 发表于 2009-6-15 18:35:00

vla-intersectwith 函数

wuweirat 发表于 2009-6-15 18:05:00

<p>好像有个函数是求交点的</p><p>要提供四个点</p><p>我不记得去了</p><p>高手指点一下</p>

happy72096 发表于 2009-6-15 18:12:00

<p>谢谢,那个是求两条直线交点的函数,我需要的是求任意两个对象交点的函数</p>

zml84 发表于 2009-6-15 18:19:00

;|;;===========================================================================<br style="line-height: 23px; "/>      通用函数                                                                ;<br style="line-height: 23px; "/>功能:求两个线条对象的交点                                                    ;<br style="line-height: 23px; "/>      适用对象: Line、Circle、Arc、Ellipse、Polyline、                        ;<br style="line-height: 23px; "/>      LWPolyline、3dPolyline、Spline                                          ;<br style="line-height: 23px; "/>参数:OBJ1   ----对象1                                                        ;<br style="line-height: 23px; "/>      OBJ2   ----对象2                                                        ;<br style="line-height: 23px; "/>      Extend ----延伸选项                                                     ;<br style="line-height: 23px; "/>                 0  acExtendNone                                              ;<br style="line-height: 23px; "/>                 1  acExtendThisEntity                                        ;<br style="line-height: 23px; "/>                 2  acExtendOtherEntity                                       ;<br style="line-height: 23px; "/>                 3  acExtendBoth                                              ;<br style="line-height: 23px; "/>      ZZZ    ----输出选项                                                     ;<br style="line-height: 23px; "/>                 "=0"  Z值取0                                                 ;<div><font class="Apple-style-span" color="#434343" face="Verdana, Arial, Helvetica, 宋体, sans-serif" size="3">...</font></div><div><font class="Apple-style-span" color="#434343" face="Verdana, Arial, Helvetica, 宋体, sans-serif" size="3">...</font></div><div><font class="Apple-style-span" color="#434343" face="Verdana, Arial, Helvetica, 宋体, sans-serif" size="3"><br/></font></div><div><font class="Apple-style-span" color="#434343" face="Verdana, Arial, Helvetica, 宋体, sans-serif" size="3"><br/></font></div><div><font class="Apple-style-span" color="#434343" face="Verdana, Arial, Helvetica, 宋体, sans-serif" size="3"><a href="http://hi.baidu.com/123523058/blog/item/22482136e1935bd5a3cc2be2.html">http://hi.baidu.com/123523058/blog/item/22482136e1935bd5a3cc2be2.html</a></font></div><div><font class="Apple-style-span" color="#434343" face="Verdana, Arial, Helvetica, 宋体, sans-serif" size="3"><br/></font></div><div><font class="Apple-style-span" color="#434343" face="Verdana, Arial, Helvetica, 宋体, sans-serif" size="3"><br/></font></div>

nzl1116 发表于 2009-6-15 18:42:00

<p>函数调用如下:</p><p>(setq interPtVar (vl-catch-all-apply 'vla-intersectwith (list vlaobj1 vlaobj2 acExtend*)))</p><p>(if (vl-catch-all-error-p interPtVar)</p><p>...</p><p>)</p>

clh521 发表于 2009-6-15 19:12:00

学习啦

hntwty 发表于 2023-10-12 12:08:23

zml84 发表于 2009-6-15 18:19
;|;;===========================================================================   &#1 ...

大神你好,这个函数好像缺少了TOXY函数,可以提供一下吗,谢谢

zml84 发表于 2023-10-12 12:16:37

hntwty 发表于 2023-10-12 12:08
大神你好,这个函数好像缺少了TOXY函数,可以提供一下吗,谢谢


;;;=================================================================*
;;;功能:曲线实体上每个控制点的z坐标值置为0.0                     *
(defun TOXY (OBJ / NAME PT1 TP2 i)
;;取得实体的类型名称
(setq NAME (vla-get-objectname OBJ))
(cond
    ;;类型1
    ;;直线(line)
    ((= NAME "AcDbLine")
   ;;取得直线的起终点坐标
   (setq PT1 (vlax-variant-value (vla-get-startpoint OBJ))
           PT2 (vlax-variant-value (vla-get-endpoint OBJ))
   )
   ;;改变z值为0.0
   (vlax-safearray-put-element PT1 2 0.0)
   (vlax-safearray-put-element PT2 2 0.0)
   (vla-put-startpoint OBJ PT1)
   (vla-put-endpoint OBJ PT2)
    )
    ;;类型2
    ;;圆(circle)
    ;;圆弧(arc)
    ;;椭圆及椭圆弧(ellipse)
    ((or (= NAME "AcDbCircle")
       (= NAME "AcDbArc")
       (= NAME "AcDbEllipse")
   )
   ;;取得中心点座标
   (setq PT1 (vlax-variant-value (vla-get-center OBJ)))
   ;;改变中心点座标z值为0.0
   (vlax-safearray-put-element PT1 2 0.0)
   (vla-put-center OBJ PT1)
    )
    ;;类型3
    ;;多段线(polyline、lwpolyline)
    ;;拟合的2维多段线(polyline、lwpolyline)
    ((or (= NAME "AcDbPolyline")
       (= NAME "AcDb2dPolyline")
   )
   ;;改变标高值为0.0
   (vla-put-elevation OBJ 0.0)
    )
    ;;类型4
    ;;三维多段线(3dpolyline)
    ((= NAME "AcDb3dPolyline")
   ;;取得3维多段线的控制点
   (setq PT1 (vlax-variant-value (vla-get-coordinates OBJ))
           I   0
   )
   (repeat (/ (length (vlax-safearray->list PT1)) 3)
       (vlax-safearray-put-element PT1 (+ I 2) 0.0)
       (setq I (+ I 3))
   )
   (vla-put-coordinates OBJ PT1)
    )
    ;;类型5
    ;;样条曲线(Spline)
    ((= NAME "AcDbSpline")
   ;;取得样条曲线的拟合点
   ;;改变每个拟合点的z值为0.0
   (setq PT1 (vlax-variant-value (vla-get-fitpoints OBJ))
           I   0
   )
   (repeat (vla-get-numberoffitpoints OBJ)
       (vlax-safearray-put-element PT1 (+ I 2) 0.0)
       (setq I (+ I 3))
   )
   (vla-put-fitpoints OBJ PT1)
   ;;取得样条曲线的控制点
   ;;改变每个控制点的z值为0.0
   (setq
       PT2 (vlax-variant-value (vla-get-controlpoints OBJ))
       I   0
   )
   (repeat (vla-get-numberofcontrolpoints OBJ)
       (vlax-safearray-put-element PT2 (+ I 2) 0.0)
       (setq I (+ I 3))
   )
   (vla-put-controlpoints OBJ PT2)
    )
    (t NIL)
)
) ;_结束defun
;;;=================================================================*

hntwty 发表于 2023-10-12 12:40:05

zml84 发表于 2023-10-12 12:16


能正常使用了,感谢大佬无私奉献
页: [1]
查看完整版本: [求助]请问有没有求任意两个对象交点的程序