Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modify polyline without changing Z value

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
yu85.info
498 Views, 7 Replies

Modify polyline without changing Z value

yu85.info
Advocate
Advocate

Hi, I have 2 3Dpolyline in my drawing. The first has the correct X Y (Lat,Lon) coordinates but not the correct Z values in the vertexes. The second is close to him has the correct Z values but not the correct  X Y. I need to move the vertexes of the second according to those of the first but without changing the Z values. Any idea for this kind of task?

Thanks in advance 

0 Likes

Modify polyline without changing Z value

Hi, I have 2 3Dpolyline in my drawing. The first has the correct X Y (Lat,Lon) coordinates but not the correct Z values in the vertexes. The second is close to him has the correct Z values but not the correct  X Y. I need to move the vertexes of the second according to those of the first but without changing the Z values. Any idea for this kind of task?

Thanks in advance 

Labels (2)
7 REPLIES 7
Message 2 of 8
cadffm
in reply to: yu85.info

cadffm
Consultant
Consultant
Accepted solution

Hi,

you can use POINTFILTERS or OSNAPZ setting

 

Sebastian

Hi,

you can use POINTFILTERS or OSNAPZ setting

 

Sebastian

Message 3 of 8
cadffm
in reply to: yu85.info

cadffm
Consultant
Consultant

Or properties palette,

but this isn't accurate (or better, you don't know the exact X Y values to set XY accurately.

Sebastian

Or properties palette,

but this isn't accurate (or better, you don't know the exact X Y values to set XY accurately.

Sebastian

Message 4 of 8
leeminardi
in reply to: yu85.info

leeminardi
Mentor
Mentor

A sample file with 3D polylines would help provide a possible solution.  It's not clear how the vertices of the 3dpoly with the correct z value correlate, if at all, with the 3dpoly with the correct x ad y values.

 

Here's an approach that might yield a satisfatory solution.

 

In the image below it is assumed that the red 3dpoly has the correct x,y values and the green 3dpoly has the correct z values  The yellow plane lies n the XY plane and is present to help visualize the 3D nature of the lines.

leeminardi_0-1706712984313.png

A copy is made of the red 3dpoly and then going to the top view flatten is used to project it to the XY plane where extrude is used to make a surface prependicular to the xy plane.  Using 3dforbit, a view is choosen that is deemed the best orientation for projecting the green 3dpoly onto the surfaces created from the red 3dpoly.  The result will look something like this.

leeminardi_1-1706713452310.pngleeminardi_2-1706713493320.png

We want the line formed by the intersetion of the magenta surfaces with the cyan surfaces.  Since there isn't a command (that I am aware of) to find the intersection of sufaces you can create thin solids for each set of surfaces by first using thicken on the surfaces with a small value and then create a single solid from all the magenta solids and then all the cyan solids.  The Boolean intersect command is then used to find the intersection of the two solids. shown in white below.

leeminardi_3-1706713988891.png

From here a 3Dpoly can be created from the vertices along one edge of the white solid.

 

 

lee.minardi

A sample file with 3D polylines would help provide a possible solution.  It's not clear how the vertices of the 3dpoly with the correct z value correlate, if at all, with the 3dpoly with the correct x ad y values.

 

Here's an approach that might yield a satisfatory solution.

 

In the image below it is assumed that the red 3dpoly has the correct x,y values and the green 3dpoly has the correct z values  The yellow plane lies n the XY plane and is present to help visualize the 3D nature of the lines.

leeminardi_0-1706712984313.png

A copy is made of the red 3dpoly and then going to the top view flatten is used to project it to the XY plane where extrude is used to make a surface prependicular to the xy plane.  Using 3dforbit, a view is choosen that is deemed the best orientation for projecting the green 3dpoly onto the surfaces created from the red 3dpoly.  The result will look something like this.

leeminardi_1-1706713452310.pngleeminardi_2-1706713493320.png

We want the line formed by the intersetion of the magenta surfaces with the cyan surfaces.  Since there isn't a command (that I am aware of) to find the intersection of sufaces you can create thin solids for each set of surfaces by first using thicken on the surfaces with a small value and then create a single solid from all the magenta solids and then all the cyan solids.  The Boolean intersect command is then used to find the intersection of the two solids. shown in white below.

leeminardi_3-1706713988891.png

From here a 3Dpoly can be created from the vertices along one edge of the white solid.

 

 

lee.minardi
Message 5 of 8
Kent1Cooper
in reply to: yu85.info

Kent1Cooper
Consultant
Consultant

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

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
Message 6 of 8
yu85.info
in reply to: Kent1Cooper

yu85.info
Advocate
Advocate

Thank you very much. The code works great but in my case the number of vertex is not to same. So I had to do it manually.

Thanks again sir

0 Likes

Thank you very much. The code works great but in my case the number of vertex is not to same. So I had to do it manually.

Thanks again sir

Message 7 of 8
Kent1Cooper
in reply to: yu85.info

Kent1Cooper
Consultant
Consultant

@yu85.info wrote:

.... in my case the number of vertex is not to same. So I had to do it manually. ....


That seems the only possible way, under the circumstances.  You would need to make choices about which vertices you assigned which values from which vertices of the other Polyline, if they don't match up one for one.  Maybe if you could define some criteria for determining that, it could be automated, but it's hard to imagine.

Kent Cooper, AIA


@yu85.info wrote:

.... in my case the number of vertex is not to same. So I had to do it manually. ....


That seems the only possible way, under the circumstances.  You would need to make choices about which vertices you assigned which values from which vertices of the other Polyline, if they don't match up one for one.  Maybe if you could define some criteria for determining that, it could be automated, but it's hard to imagine.

Kent Cooper, AIA
Message 8 of 8
yu85.info
in reply to: Kent1Cooper

yu85.info
Advocate
Advocate

Its ok sir, do not bother yourself sometimes I just have to deal with my mistakes manually 🙂

0 Likes

Its ok sir, do not bother yourself sometimes I just have to deal with my mistakes manually 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report