broncos15 发表于 2022-7-5 18:52:42

hanhphuc你是对的,可能有两个答案:2d和3d max。

BIGAL 发表于 2022-7-5 18:56:39

这就是我的代码所在。您可以看到,我只对pt2使用了vlax曲线getClosestPointto。然而,这实际上并不总是给出垂直点,因为它考虑了包括z值在内的距离。
(defun c:maxheight(/*error*maxdist ss1 ss2 pt3 pt4)(defun*error*(msg)(if(not(member msg)(“Function cancelled”“quit/exit abort”))(princ(strcat”\error:“msg”))(princ))(if(and(和(setq ss1(LM:ssget“\n选择第一条三维多段线/要素线:”(“+:E:S”((0。“多段线,AECC\u要素线”))))(setq ss2(LM:ssget)“\n选择第二条三维多段线/要素线:”(“+:E:S”((0。“Polyline,AECC\u Feature\u Line”))))(progn(maxheight:mainprogram)(maxheight:ans)))(princ));;;这是代码的答案部分(defun maxheight:ans()(initget“Yes No”)(setq*maxheightans*(cond((getkword(strcat“\n在最大高度位置绘制一行:”))(*maxheightans*))(if(=*maxheightans*“Yes”)(progn(命令“.u line”pt3 pt4”“)(命令“.u zoom”“\u W”pt3 pt4))(警报(strcat)“\n实体之间的最大垂直距离为:”(rtos maxdist 2 2)))(princ(strcat“\n实体之间的最大垂直距离为:”(rtos maxdist 2 2)));;;主代码部分(defun maxheight:mainprogram(/ent1 ent2 len delta pt1 pt2 z1 z2 maxdist1)(setq ent1(vlax ename->vla object(ssname ss1 0))ent2(vlax ename->vla object(ssname ss2 0))delta 0.0maxdist 0.0)(如果(

hanhphuc 发表于 2022-7-5 18:58:20

BIGAL 发表于 2022-7-5 19:02:18

hanhphuc you are right maybe two answers 2d & 3d max.

broncos15 发表于 2022-7-5 19:05:56

So this is where my code is at now. You can see that I just use the vlax-curve-getClosestPointto for pt2. However, this doesn't actually always give the perpendicular point because it takes into the account the distance including the z value.
(defun c:maxheight (/ *error* maxdist ss1 ss2 pt3 pt4) (defun *error* (msg)   (if (not(member msg '("Function cancelled" "quit / exit abort")))   (princ (strcat "\nError: " msg))   )   (princ) ) (if (and (setq ss1   (LM:ssget "\nSelect 1st 3D Polyline/Feature Line: "      '("_+.:E:S" ((0 . "POLYLINE,AECC_FEATURE_LINE")))   )   )   (setq ss2   (LM:ssget "\nSelect 2nd 3D Polyline/Feature Line: "      '("_+.:E:S" ((0 . "POLYLINE,AECC_FEATURE_LINE")))   )   )   )   (progn   (maxheight:mainprogram)   (maxheight:ans)   ) ) (princ));;;This is the answer portion of the code(defun maxheight:ans () (initget "Yes No") (setq *maxheightans* (cond   (    (getkword      (strcat "\nDraw a line at max height location : "      )    )   )   (*maxheightans*) ) ) (if (= *maxheightans* "Yes")   (progn   (command "._line" pt3 pt4 "")   (command "._zoom" "_W" pt3 pt4)   ) ) (alert(strcat"\nThe maximum vertical distance between the entities is: "(rtos maxdist 2 2))   ) (princ(strcat"\nThe maximum vertical distance between the entities is: "(rtos maxdist 2 2))   ));;;Main code portion(defun maxheight:mainprogram (/ ent1 ent2 len delta pt1 pt2 z1 z2 maxdist1) (setq ent1 (vlax-ename->vla-object (ssname ss1 0))ent2 (vlax-ename->vla-object (ssname ss2 0))delta 0.0maxdist 0.0 ) (if (
页: 1 [2]
查看完整版本: 如何在p上迭代点