Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Kent1Cooper
en respuesta a: yu85.info

Will the two of them always have the same number of vertices?  If so, it should not be complicated to use the 'Coordinates VLA property, and just replace every third number [the Z coordinate of each vertex] in one of them with those from the other, then impose the revised list on the one you want to change.  Does that sound like it would work?

EDIT:

For example, this works for me [in minimal testing]:

 

(defun C:3DPXYR ; = 3DPolyline XY coordinates Replacement
  (/ 3dXY 3dZ XYobj Xobj XYcoords Zcoords n newcoords)
  (if
    (and
      (setq 3dXY (car (entsel "\n3DPoly with correct XY coordinate values: ")))
      (member '(100 . "AcDb3dPolyline") (entget 3dXY))
      (setq 3dZ (car (entsel "\n3DPoly with correct Z values to have other's XY values imposed: ")))
      (member '(100 . "AcDb3dPolyline") (entget 3dXY))
      (= (vlax-curve-getEndParam 3dXY) (vlax-curve-getEndParam 3dZ)); same # of vertices
      (= (vlax-curve-isClosed 3dXY) (vlax-curve-isClosed 3dZ)); either both closed or both open
    ); and
    (progn ; then
      (setq
        XYobj (vlax-ename->vla-object 3dXY)
        Zobj (vlax-ename->vla-object 3dZ)
        XYcoords (vlax-get XYobj 'Coordinates)
        Zcoords (vlax-get Zobj 'Coordinates)
      ); setq
      (repeat (setq n (length Zcoords))
        (setq newcoords
          (cons
            (nth
              (setq n (1- n))
              (if (= (rem n 3) 2) Zcoords XYcoords)
                ; take every third one from Z list, others from XY
            ); nth
            newcoords
          ); cons
        ); setq
      ); repeat
      (vlax-put Zobj 'Coordinates newcoords); impose revised coordinates
    ); progn
    (prompt "\nMust be two 3DPolylines with same number of vertices."); else
  ); if
  (prin1)
)

 

It could omit the check on whether they're either both open or both closed, if preferred, or the no-go prompt could be extended to mention that requirement.

Kent Cooper, AIA