Jump to content

Recommended Posts

Posted

Does anyone have a lisp solution to joint the equally spaced points a long two separate lines opposite eachother. The lines may be curved and may not be parallel.

 

The idea is that the program would work along two lines in a chosen direction and everytime it hits a point on the lines it joins them with a polyline.

 

I don't know if this is clear

 

Many thanks

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • ymg3

    13

  • churchntj

    12

  • BIGAL

    1

  • Bhull1985

    1

Top Posters In This Topic

Posted Images

Posted

A way using lisp, not code use divide create points then join the points if say 5 pts per line then 1-6 2-7 3-8 4-9 5-10. Some one may have have to go and do work now.

Posted (edited)

So I think I understand your post. In my situation the points are already there; I have already used > and I would like Autocad to join the points along the lines working along them from one end. So what I am looking for doesn't need this step.

 

I have done MATLAB coding so have a general understanding of coding but dont know LISP. Does anyone have any ideas of how to put some code together to achieve this?

 

Thanks

Edited by churchntj
Misunderstood the post above
Posted

churchntj,

 

List the vertices of both polylines, then entmakex the lines taking

first endpoint in list1 and second from list2

 

(defun c:test (/ a b lst1 lst2)

 
   ;;; listpol   by Gille Chanteau                                            ;
   ;;; Returns the vertices list of any type of polyline (WCS coordinates)    ;
   ;;;                                                                        ;
   ;;; Argument                                                               ;
   ;;; en, a polyline (ename or vla-object)                                   ;

   (defun listpol (en / i p l)  
      (setq i (if (vlax-curve-IsClosed en)
 	         (vlax-curve-getEndParam en)
         (+ (vlax-curve-getEndParam en) 1)
      )
      )	      
      (while (setq p (vlax-curve-getPointAtParam en (setq i (1- i))))
        (setq l (cons (trans p 0 1 ) l))
      )
   )
  ;---------------------------------------------------------------------------------;

   (setq lst1 (listpol (car (entsel "\Select First Polyline: ")))
  lst2 (listpol (car (entsel "\Select Second Polyline: ")))
   )
   (mapcar '(lambda (a b) (entmakex (list (cons 0  "LINE")
				   (cons 10 a)
				   (cons 11 b)
			     )
	           )
      ) lst1 lst2)
)

Posted

Well done ymg, your use of mapcar and lambda in this routine are fairly self-explinatory and help in my understanding of the functions. For that I am very gracious.

Thank you!

Posted

bhull,

 

Thanks! for the kind words. :)

 

ymg

Posted

Thank you very much that looks great.

Am not currently on a PC with Autocad. Would this LISP work with points along two splines, poylines, arcs etc or combinations?

 

Thanks.

Posted

churchntj,

 

It will work with arc.

 

With spline whatever vertex are defined by the vlax-curve function

will be joined. (these are different than the control point used to create the spline)

 

So we may say it works.

 

ymg

churcjntj.jpg

Posted

Hey There,

 

Ok, back at work and have tried out the lisp. I'm not sure I was very clear in expressing what I was looking for.

So actually I am looking for points that have been placed on a line, polyline, spline or arc, to joint with points placed on another line. Also ideally the points would be joined by a polyline not a line. It looks the same as the image that you showed except those points are joined are put there and are not vertices of the polyline.

I would include an attachment but am having issues uploading anything to the forum.

Posted

churchntj,

 

The following requires Express Tools installed on your system.

 

Polylines are used as fence to select the points.

 

(defun c:joinpt (/ a b en1 en2 enl1 enl2 flt lst1 lst2 p)



  ;;*************************************************************************;
  ;; getfencesel        by ymg                                               ;
  ;;                                                                         ;
  ;; Arguments:  en,  Linear Entity Name (Polylines, Arc, Ellipse etc.)      ;
  ;;            flt,  A valid Entity filer Ex: '((0 . "3DFACE"))  or nil     ;
  ;;                                                                         ;
  ;;   Returns: A Selection Set of Entities touching the selecting entity.   ;
  ;;                                                                         ;
  ;;  Requires: Express Tools                                                ;
  ;;*************************************************************************;

  (defun getfencesel (en flt / fe px ss)    
     (acet-ss-zoom-extents (setq ss (ssadd en)))
     (setq px (* 0.75 (acet-geom-pixel-unit))
           fe (acet-list-remove-adjacent-dups (acet-geom-object-point-list en (/ px 2.0)))
           ss (if flt (ssget "_F" fe flt) (ssget "_F" fe))
     )      
  )

  ;;*************************************************************************;
  ;; mk_lwp    by Alan J Thompson                                            ;
  ;; Argument: pl, A list of points (2d or 3d)                               ;
  ;; Create an LWPolyline at Elevation 0, on Current Layer.                  ;
  ;; Return: Polyline Object                                                 ;
  ;;*************************************************************************;

  (defun mk_lwp (pl)
     (vlax-ename->vla-object
        (entmakex
          (append (list '(0 . "LWPOLYLINE")
                        '(100 . "AcDbEntity")
                        '(100 . "AcDbPolyline")
                         (cons 90 (length pl))
                        '(70 . 0)
                  )
                  (mapcar '(lambda (p) (cons 10 (trans (list (car p) (cadr p)) 1 0))) pl)
          )
       )
     )
  )

  (setq en1 (car (entsel "\nSelect First Polyline: "))
 en2 (car (entsel "\nSelect Second Polyline: "))
 flt '((0 . "POINT"))
       enl1 (acet-ss-to-list (getfencesel en1 flt))
enl2 (acet-ss-to-list (getfencesel en2 flt))
 
  )
  (setq lst1 nil lst2 nil)
  (foreach e enl1
     (setq lst1 (cons (cdr (assoc 10 (entget e))) lst1))
  )	    
  (foreach e enl2
     (setq lst2 (cons (cdr (assoc 10 (entget e))) lst2))
  )
  (mapcar '(lambda (a b) (mk_lwp (list a b))) lst1 lst2)
  (princ)
)     

 

Points are join with LWPOLYLINES with the help of AlanJT's routine

churchntj2.jpg

Posted

That's great it now works perfectly apart from the fact that I can't seem to make it work with arcs.

Posted

churdchntj,

 

In the image I posted for this version, top polyline has two arcs

and bottom one is a spline.

 

One problem could be that we are approximating the fence with

straight line segments. Your target is kind of small being points.

 

So in the case of very tight arc, It could miss.

 

ymg

Posted

I have tried a few times and can't get it to work with either just arcs or arcs within a set of polylines. THis is what my command line does:

(It has occurred to me that, I am working in French AutoCAD, so could this be having an effect? So far I haven't had a problem with this)

 

Commande: JOINPT

Select First Polyline:

Select Second Polyline: _.zoom

Spécifiez le coin d'une fenêtre, entrez un facteur d'échelle (nX ou nXP) ou

[Tout/Centre/DYnamique/ETendu/Précédent/Echelle/Fenêtre/Objet] : _w

Spécifiez le premier coin: Spécifiez le coin opposé:

Commande: _.zoom

Spécifiez le coin d'une fenêtre, entrez un facteur d'échelle (nX ou nXP) ou

[Tout/Centre/DYnamique/ETendu/Précédent/Echelle/Fenêtre/Objet] : _w

Spécifiez le premier coin: Spécifiez le coin opposé:

Commande:

Posted

churchntj,

 

Are you sure you got Express Tools Installed ??

 

You should receive a prompt to Select the First Polyline

then the Another prompt to Select the Second then

Command proceed with drawing the line.

 

Right Now you are breaking up at (acet-ss-zoom-extents (setq ss (ssadd en)))

which is the very first Express Tools being called.

 

ymg

Posted

ymg3,

 

Express Tools is Installed and working. The lsp works well with normal polylines.

The two prompts work and it is upon clicking on the second line that the error occurs:

 

Select First Polyline:

Select Second Polyline: _.zoom

Spécifiez le coin d'une fenêtre, entrez un facteur d'échelle (nX ou nXP) ou

[Tout/Centre/DYnamique/ETendu/Précédent/Echelle/Fenêtre/Objet] : _w

Spécifiez le premier coin: Spécifiez le coin opposé: *Incorrect*

; erreur: Fonction annulée

Posted

churchntj,

 

C'est a ce moment que la fonction "acet-ss-zoom-extents"

est appelée.

 

Forcément c'est la que le problème se situe.

 

Autre possibilité si l'étendue de ton dessin est très grande.

 

Fais un essai en enlevant la première ligne de la fonction (getfencesel)

 

ymg

Posted

churchntj,

 

Essaye en remplaçant la fonction "getfencesel"

par la suivante:

 

;;*************************************************************************;
  ;; getfencesel        by ymg                                               ;
  ;;                                                                         ;
  ;; Arguments:  en,  Linear Entity Name (Polylines, Arc, Ellipse etc.)      ;
  ;;            flt,  A valid Entity filer Ex: '((0 . "3DFACE"))  or nil     ;
  ;;                                                                         ;
  ;;   Returns: A Selection Set of Entities touching the selecting entity.   ;
  ;;                                                                         ;
  ;;  Requires: Express Tools                                                ;
  ;;*************************************************************************;

  (defun getfencesel (en flt / fe px ss)    
     (vl-cmdf "_ZOOM" "_O" en "")
     (setq px (* 0.75 (acet-geom-pixel-unit))
           fe (acet-list-remove-adjacent-dups (acet-geom-object-point-list en (/ px 2.0)))
           ss (if flt (ssget "_F" fe flt) (ssget "_F" fe))
     )      
  )

Posted

No, ca ne marche toujours pas!?

Posted

churchntj,

 

Can you upload your drawing where it does not work.

 

Save it as release 2010, I don't have 2014

 

ymg

Posted

churchntj,

 

Are you by any chance using Windows 8,

cause if it is the case some of your command

in Express Tools might not work.

 

ymg

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