Jump to content

Add POINT at Pline corners


mousho

Recommended Posts

@Grrr, if you still haven't debugged it, I've updated code, so you can see where the problem was - glad that you used VLIDE and tried to fix the issue on your own way... The problem was that "mp" midpoint variable was calculated even if parameter of polyline that was incremented was "endparameter" - last one - so actually (vlax-curve-getpointatparam pl (+ k 0.5)) is nil as (+ k 0.5) is exceeded maximum value of "endparameter" - so to fix it I've put condition for what range "mp" should be calculated...

 

@sanjeeve, to create points of line sequences in 3D, you'll have to connect them into 3DPOLY entity and then apply code from #4 :

http://www.cadtutor.net/forum/showthread.php?96374-Add-POINT-at-Pline-corners&p=#4

To convert connected lines to 3dpolyline entity, try this code :

(defun c:l3dpl ( / CHOICE1 CHOICE2 ENENT ENPT ENPTT ENT K NXTENTEN NXTENTST OSM PTLST SEPT SEPTN SEPTS SS SSS STENT STPT )
 (vl-cmdf "_.UCS" "w")
 (setq osm (getvar 'osmode))
 (setvar 'osmode 0)
 (prompt "\nSelect all connected lines")
 (setq ss (ssget '((0 . "LINE")) ))
 (setq sss (ssadd))
 (repeat (setq k (sslength ss))
   (setq ent (ssname ss (setq k (1- k))))
   (ssadd ent sss)
 )    
 (repeat (setq k (sslength ss))
   (setq ent (ssname ss (setq k (1- k))))
   (setq stpt (cdr (assoc 10 (entget ent))))
   (setq enpt (cdr (assoc 11 (entget ent))))
   (setq septs (cons stpt septs))
   (setq septs (cons enpt septs))
 )
 (setq sept septs)
 (defun chkduppt (pt lst / chk)
   (foreach ptt lst
     (if (equal pt ptt 1e-6) (setq chk (cons T chk)))
   )
   chk
 )
 (foreach pt septs
   (if (eq (length (chkduppt pt septs)) 2) (setq septn (cons pt septn)))
 )
 (foreach pt septn
   (setq sept (vl-remove pt sept))
 )
 (if (eq sept nil) (setq sept (acet-list-remove-duplicates septs 1e-6)))
 (repeat (setq k (sslength ss))
   (setq ent (ssname ss (setq k (1- k))))
   (setq stpt (cdr (assoc 10 (entget ent))))
   (if (equal stpt (car sept) 1e-6) (setq stent ent))
 )
 (if (eq stent nil)
   (repeat (setq k (sslength ss))
     (setq ent (ssname ss (setq k (1- k))))
     (setq enpt (cdr (assoc 11 (entget ent))))
     (if (equal enpt (car sept) 1e-6) (setq enent ent))
   )
 )
 (if stent
 (progn
   (setq ptlst (cons (cdr (assoc 10 (entget stent))) ptlst))
   (setq ptlst (cons (cdr (assoc 11 (entget stent))) ptlst))
   (setq enpt (cdr (assoc 11 (entget stent))))
   (ssdel stent ss)
 )
 (progn
   (setq ptlst (cons (cdr (assoc 11 (entget enent))) ptlst))
   (setq ptlst (cons (cdr (assoc 10 (entget enent))) ptlst))
   (setq enpt (cdr (assoc 10 (entget enent))))
   (ssdel enent ss)
 )
 )
 (while (/= (sslength ss) 0)
   (setq nxtentst nil)
   (setq nxtenten nil)
   (repeat (setq k (sslength ss))
     (setq ent (ssname ss (setq k (1- k))))
     (setq stpt (cdr (assoc 10 (entget ent))))
     (if (equal enpt stpt 1e-6) (setq nxtentst ent))
   )
   (if nxtentst nil
     (repeat (setq k (sslength ss))
       (setq ent (ssname ss (setq k (1- k))))
       (setq enptt (cdr (assoc 11 (entget ent))))
       (if (equal enpt enptt 1e-6) (setq nxtenten ent))
     )
   )
   (if nxtentst
   (progn
     (setq ptlst (cons (cdr (assoc 10 (entget nxtentst))) ptlst))
     (setq ptlst (cons (cdr (assoc 11 (entget nxtentst))) ptlst))
     (setq enpt (cdr (assoc 11 (entget nxtentst))))
     (ssdel nxtentst ss)
   )
   (progn
     (setq ptlst (cons (cdr (assoc 11 (entget nxtenten))) ptlst))
     (setq ptlst (cons (cdr (assoc 10 (entget nxtenten))) ptlst))
     (setq enpt (cdr (assoc 10 (entget nxtenten))))
     (ssdel nxtenten ss)
   )
   )
 )
 (setq ptlst (acet-list-remove-duplicates ptlst 1e-6))
 (initget 1 "Open Close")
 (setq choice1 (getkword "\nIs 3dpolyline opened or closed (Open/Close) : "))
 (if (eq choice1 "Open")
   (progn
   (command "_.3dpoly")
   (foreach pt ptlst
     (command pt)
   )
   (command "")
   )
   (progn
   (command "_.3dpoly")
   (foreach pt ptlst
     (command pt)
   )
   (command "c")
   )
 )
 (initget 1 "Keep Delete")
 (setq choice2 (getkword "\nDo you want to keep lines, or do you want me to delete them (Keep/Delete) : "))
 (if (eq choice2 "Delete")
   (command "erase" sss "")
 )
 (vl-cmdf "_.UCS" "p")
 (setvar 'osmode osm)
 (princ)
)

P.S. If sequence order is opposite of what should be, "UNDO" operation, apply "REVERSE" command to 3dpolyline and try making point sequence again...

 

Regards, M.R.

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • marko_ribar

    6

  • Grrr

    4

  • sanjeeve

    4

  • mousho

    2

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