subodh_gis 发表于 2022-7-5 20:55:08

如何获得第一个和第二个ve

我喜欢在选定多段线的第一个顶点和第二个顶点之间编写文本。
请帮助我获取多段线的第一个顶点(p1)和第二个顶点(p2)。剩下的事我自己可以做。
 
提前感谢

BlackBox 发表于 2022-7-5 21:07:47

考虑vlax Curve GetStartPoint和vlax Curve GetPointAtParam函数。
 
干杯

BIGAL 发表于 2022-7-5 21:09:32

这里是第1个和第2个的另一个示例,只需使用(getcoords)并查看前4个值。
 

; pline co-ords by BIG AL
(defun plcords (/ ent obj plobs )
(vl-load-com)
(defun getcoords (ent)
(vlax-safearray->list
   (vlax-variant-value
   (vlax-get-property
   (vlax-ename->vla-object ent)
   "Coordinates"
   )
   )
)
)

(defun co-ords2xy ( / I)
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 2))
(setq I 0)
(repeat numb
(setq xy (list (nth (+ I 1) co-ords)(nth I co-ords) ))
(setq coordsxy (cons xy coordsxy))
(setq I (+ I 2))
) ; end repeat
)

(setq plobjs (ssget (list (cons 0 "lwpolyline"))))
(setq numb1 (sslength plobjs))
(setq x numb1)

(repeat numb1
(setq obj (ssname plobjs (setq x (- x 1))))
(setq co-ords (getcoords obj))
)
(co-ords2xy)

(setq inc (length coordsxy))
(repeat (/ inc2)
(setq x (rtos (nth (setq inc (- inc 1)) co-ords) 2 3 ))
(setq y (rtos (nth (setq inc (- inc 1)) co-ords) 2 3 ))
(setq xy (strcat x "," y ))
(princ xy)
(princ "\n ")
)
)
(plcords)

Tharwat 发表于 2022-7-5 21:19:03

试试这个。
 

(if (and (setq s (car (entsel "\n Select Polyline :")))
      (eq (cdr (assoc 0 (setq e (entget s)))) "LWPOLYLINE")
   )
(progn
   (setq d (distance (setq 1p (cdr (car (setq l
                                             (vl-remove-if-not '(lambda (u) (eq (car u) 10)) e)
                                        )
                                 )
                              )
                     )
                     (setq 2p (cdr (cadr l)))
         )
         a (angle 1p 2p)
   )
   (command "text"
            "mc"
            (mapcar '(lambda (q p) (* (+ q p) 0.5)) 1p 2p)
            0.2
            (/ (* a 180) pi)
            (strcat (rtos d 2 2) "/BT/RD")
   )
)
)

Tharwat 发表于 2022-7-5 21:23:40

 
不客气

Tharwat 发表于 2022-7-5 21:30:41

 
这是否意味着要从多段线获得两个偏移?我不清楚,请提供更多信息。

Tharwat 发表于 2022-7-5 21:38:02

 
最好给出一个示例图或一个图像来一次性编写代码。
注:我不会在例程中包括李的例程,只要一个双偏移量就足够了。

Tharwat 发表于 2022-7-5 21:43:51

这里面有什么?
 

(defun c:Test (/ s en e sn l ly o dz d a 1p 2p)
;;        Tharwat 08.12.2014        ;;
(princ "\n Select Polyline :")
(if (and (setq en (entlast)
                s(ssget "_+.:S:E:L" '((0 . "LWPOLYLINE")))
          )
          (setq dz (getvar 'DIMZIN))
          (setvar 'DIMZIN 0)
          (setq *offDist*
               (cond ((getdist (strcat "\n Specify offset distance <"
                                       (rtos (if *offDist*
                                                 *offDist*
                                                 (setq *offDist* 1.0)
                                             )
                                             2
                                             2
                                       )
                                       " > :"
                                 )
                        )
                     )
                     (*offDist*)
               )
          )
          (progn
            (initget 6 "Current Source")
            (setq ly
                   (cond
                     ((getkword
                        "\n Enter layer option for offset objects <Source>: "
                      )
                     )
                     ("Source")
                   )
            )
          )
   )
   (progn
   (setq d (distance (setq 1p (cdr (car (setq l
                                                 (vl-remove-if-not
                                                   '(lambda (u) (eq (car u) 10))
                                                   (setq e (entget (setq sn (ssname s 0))))
                                                 )
                                          )
                                     )
                              )
                     )
                     (setq 2p (cdr (cadr l)))
             )
         a (angle 1p 2p)
   )
   (foreach x (list *offDist* (- *offDist*))
       (vla-offset (vlax-ename->vla-object sn) x)
       (if (and (eq ly "Current")
                (not (eq en (setq o (entlast))))
         )
         (vla-put-layer (vlax-ename->vla-object o) (getvar 'CLAYER))
       )
   )
   (command "text"
            "mc"
            (mapcar '(lambda (q p) (* (+ q p) 0.5)) 1p 2p)
            0.2
            (/ (* a 180) pi)
            (strcat (rtos d 2 2) "/BT/RD")
   )
   )
)

(if dz
   (setvar 'DIMZIN dz)
)
(princ)
)(vl-load-com)

Tharwat 发表于 2022-7-5 21:53:34

 
我修改了上面的程序,为偏移过程添加了一个图层选项,所以请尝试一下并告诉我。

Tharwat 发表于 2022-7-5 22:01:38

 
不客气。
页: [1]
查看完整版本: 如何获得第一个和第二个ve