Jump to content

Recommended Posts

Posted

I have lines with x,y coordinate, but i havent z coordinate. On the same work i have points with same x,y coordinate, and that points have z coordinate. I want merge that points with lines, and then i will have lines with z coordinate. Any body have some lisp script for that, thx

Posted

If I understand you correctly:

 (defun c:PointMerge ( / ss i e pt zl ) (vl-load-com)    (if (setq ss (ssget "_:L" '((0 . "LINE,POINT"))))     (progn       (repeat (setq i (sslength ss))         (if (eq "POINT" (cdr (assoc 0 (entget (setq e (ssname ss (setq i (1- i))))))))           (progn             (setq zl (cons (cdr (assoc 10 (entget e))) zl)) (ssdel e ss)           )         )       )       (repeat (setq i (sslength ss))         (setq e (entget (ssname ss (setq i (1- i)))))                  (foreach x '(10 11) (setq pt (cdr (assoc x e)) pt (list (car pt) (cadr pt)))           (if             (setq pt               (car                 (vl-member-if                   (function                     (lambda ( x )                       (equal (list (car x) (cadr x)) pt 1e-                     )                   )                   zl                 )               )             )             (setq e (subst (cons x pt) (assoc x e) e))           )         )         (entmod e)       )     )   )    (princ) )

EDIT: What's up with the code formatting? :unsure:

Posted
What is going on with the formatting?

 

Is it my browser/vlide settings or do your posts give the same result?

Posted
Is it my browser/vlide settings or do your posts give the same result?

 

I can see formatting codes within a quote, I don't have access to any of the options (code brackets, bold, formatting, etc.) and I can't use macros such as Ctrl+B.

Posted

(if (setq ss (ssget "_:L" '((0 . "LINE,POINT"))))

Posted

Reformatted my code:

 

(defun c:PointMerge ( / ss i e pt zl ) (vl-load-com)
 
 (if (setq ss (ssget "_:L" '((0 . "LINE,POINT"))))
   (progn
     (repeat (setq i (sslength ss))
       (if (eq "POINT" (cdr (assoc 0 (entget (setq e (ssname ss (setq i (1- i))))))))
         (progn
           (setq zl (cons (cdr (assoc 10 (entget e))) zl)) (ssdel e ss)
         )
       )
     )
     (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i)))))
       
       (foreach x '(10 11) (setq pt (cdr (assoc x e)) pt (list (car pt) (cadr pt)))
         (if
           (setq pt
             (car
               (vl-member-if
                 (function
                   (lambda ( x )
                     (equal (list (car x) (cadr x)) pt 1e-
                   )
                 )
                 zl
               )
             )
           )
           (setq e (subst (cons x pt) (assoc x e) e))
         )
       )
       (entmod e)
     )
   )
 )
 (princ)
)

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...