Jump to content

Converting pline to 3dpolyline by taking z valves from near points


cadshekar

Recommended Posts

I need some thing like if we select the pline, lisp shall extract x and y valve from the pline and z valve shall be considred by the points on which pline has snapped. Please help...

Link to comment
Share on other sites

Try this :

 

(defun plvertlst ( entpl / ptlst )
 (setq ptlst (mapcar '(lambda ( a ) (list (car a) (cadr a) (cdr (assoc 38 (entget entpl))))) (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= (car x) 10)) (entget entpl)))))
 ptlst
)

(defun nodpt ( entpt / pt )
 (setq pt (cdr (assoc 10 (entget entpt))))
 pt
)

(defun c:pl23dplbyneanods ( / plptlst entpl sspt n nodptlst elev 3dplpt 3dplptlst )
 (setq plptlst (plvertlst (setq entpl (car (entsel "\nPick LWPOLYLINE")))))
 (setq sspt (ssget "_X" '((0 . "POINT"))))
 (setq n (sslength sspt))
 (while (> n 0)
   (setq nodptlst (append nodptlst (list (nodpt (ssname sspt (setq n (1- n)))))))
 )
 (foreach plpt plptlst
   (setq elev (caddr (car (vl-sort nodptlst '(lambda ( a b ) (<= (distance a plpt) (distance b plpt)))))))
   (setq 3dplpt (list (car plpt) (cadr plpt) elev))
   (setq 3dplptlst (cons 3dplpt 3dplptlst))
 )
 (setq 3dplptlst (reverse 3dplptlst))
 (entmake 
   (list
     '(0 . "POLYLINE")
     '(100 . "AcDbEntity")
     '(100 . "AcDb3dPolyline")
     '(66 . 1)
     '(62 . 3)
     '(10 0.0 0.0 0.0)
     (cons 70 (+ 8 (cdr (assoc 70 (entget entpl)))))
     '(210 0.0 0.0 1.0)
   )
 )
 (foreach pt 3dplptlst
   (entmake
     (list
       '(0 . "VERTEX")
       '(100 . "AcDbEntity")
       '(100 . "AcDbVertex")
       '(100 . "AcDb3dPolylineVertex")
       (cons 10 pt)
       '(70 . 32)
     )
   )
 )
 (entmake
   (list
     '(0 . "SEQEND")
     '(100 . "AcDbEntity")
   )
 )
 (princ)
)
(defun c:ptpl3dpl nil (c:pl23dplbyneanods))
(prompt "\nInvoke with : ptpl3dpl")
(princ)

 

M.R.

Link to comment
Share on other sites

This is the programme I have wrtiten to extract z value of point which is laying at the start point. But it is not at all working. Can any one help me in this...please.... Please see the attached in the prevoius replay . Convert pline to 3dpoly. dwg.

(defun c:3pl()

(setq file "d:\3dpoly.csv")

(setq f (open file "w"))

(setvar "cmdecho" 0)

(setq a (entsel "\nselect polyline:"))

(setq b (car a))

(setq c (entget b))

(setq v (cdr (nth 9 c)))

 

(setq p 14)

 

(setq d1 (nth p c))

(Setq x (cadr d1))

(setq y (caddr d1))

(setq x1 (- x 0.02))

(setq y1 (+ y 0.02))

(setq x2 (+ x 0.05))

(setq y2 (- y 0.05))

(setq w (list x1 y1))

(setq W1(list x2 y2))

(Setq z2(strcat "(" (rtos x) "," (rtos y) ")"))

(setq z3 (getpoint "\nselect point:" "node" z2)))

 

 

 

 

)

Link to comment
Share on other sites

  • 6 years later...
On 12/11/2012 at 5:02 PM, marko_ribar said:

Try this :

 

 


(defun plvertlst ( entpl / ptlst )
 (setq ptlst (mapcar '(lambda ( a ) (list (car a) (cadr a) (cdr (assoc 38 (entget entpl))))) (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= (car x) 10)) (entget entpl)))))
 ptlst
)

(defun nodpt ( entpt / pt )
 (setq pt (cdr (assoc 10 (entget entpt))))
 pt
)

(defun c:pl23dplbyneanods ( / plptlst entpl sspt n nodptlst elev 3dplpt 3dplptlst )
 (setq plptlst (plvertlst (setq entpl (car (entsel "\nPick LWPOLYLINE")))))
 (setq sspt (ssget "_X" '((0 . "POINT"))))
 (setq n (sslength sspt))
 (while (> n 0)
   (setq nodptlst (append nodptlst (list (nodpt (ssname sspt (setq n (1- n)))))))
 )
 (foreach plpt plptlst
   (setq elev (caddr (car (vl-sort nodptlst '(lambda ( a b ) (<= (distance a plpt) (distance b plpt)))))))
   (setq 3dplpt (list (car plpt) (cadr plpt) elev))
   (setq 3dplptlst (cons 3dplpt 3dplptlst))
 )
 (setq 3dplptlst (reverse 3dplptlst))
 (entmake 
   (list
     '(0 . "POLYLINE")
     '(100 . "AcDbEntity")
     '(100 . "AcDb3dPolyline")
     '(66 . 1)
     '(62 . 3)
     '(10 0.0 0.0 0.0)
     (cons 70 (+ 8 (cdr (assoc 70 (entget entpl)))))
     '(210 0.0 0.0 1.0)
   )
 )
 (foreach pt 3dplptlst
   (entmake
     (list
       '(0 . "VERTEX")
       '(100 . "AcDbEntity")
       '(100 . "AcDbVertex")
       '(100 . "AcDb3dPolylineVertex")
       (cons 10 pt)
       '(70 . 32)
     )
   )
 )
 (entmake
   (list
     '(0 . "SEQEND")
     '(100 . "AcDbEntity")
   )
 )
 (princ)
)
(defun c:ptpl3dpl nil (c:pl23dplbyneanods))
(prompt "\nInvoke with : ptpl3dpl")
(princ)
Why i can't run this lisp? Im getting this error when i select polyline
Pick LWPOLYLINE; error: bad argument type: lselsetp nil

 

Link to comment
Share on other sites

  • 10 months later...
On 12/19/2018 at 10:39 PM, Roy_043 said:

@drdownload18

Maybe there are no points in your dwg? Please test with the dwg in the OP first.

Tnx it works now. Is it possible to enable multiple polyline selection for conversion?

Link to comment
Share on other sites

The other option is to use a ssget to look for a "POINT" at the pline vertice much easier in particular OP wants to do multiple only problem may be if you are missing a point.

 

Something like this p1 is pline vertice.

(setq p2 (polar p1 (* pi 0.25) scalef))
(setq p3  (polar p1 (* pi 1.25) scalef))
(setq ss2 (ssget "CP" (list p2 p3)(list (cons 0 "Point")) ))

Looking at your sample dwg what I have suggested with code would result in "You have a pline vertice with no corresponding point now exiting"

 

How are you making the points in the 1st place from a csv ptnum,x,y,desc then there are better ways to do the line work from the point file.

 

For fun triangulated with Civ3d

image.png.13ef4abc4f262fe8efa144499b86fa6a.png

Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...