Jump to content

Recommended Posts

Posted

I am looking for an application to solve the following problem:

I have a drawing with many points p1, p2, ... pn.

Ability to select a point and to draw lines from selected point to the other points in the drawing.

Thanks.

Posted

Would this help you with it .... ? :)

 

(defun c:TesT (/ ss p i sname p1 a)
 ;; Tharwat 07. Oct. 2011 ;;
 (if (setq ss (ssget '((0 . "POINT"))))
   (progn
     (setq p (assoc 10 (entget (ssname ss 0))))
     (repeat (setq i (sslength ss))
       (setq sname (ssname ss (setq i (1- i))))
       (setq p1 (cdr (assoc 10 (entget sname))))
       (entmakex (list '(0 . "LINE") p (setq a (cons 11 p1))))
       (setq p (cons 10 (list (nth 1 a) (nth 2 a) (nth 3 a))))
     )
   )
   (princ)
 )
 (princ)
)

 

Tharwat

Posted

The routes of connecting points with lines would be according to the creation of points one by one which means the point which is created first

in a drawing would have the property in advance .

 

Regards.

Posted

Thanks for quick response.

My English is not good, the requirement is slightly different .... I hope to be suggestive photo attached!

From the point selected will draw lines to other points.

aa24.jpg

Posted

To get the best result as you are looking for , select the base point first and after that the rest of points . :)

 

Try this ..

 

(defun c:TesT (/ ss p i sname p1 )
 ;; Tharwat 07. Oct. 2011 ;;
 (if (setq ss (ssget '((0 . "POINT"))))
   (progn
     (setq p (assoc 10 (entget (ssname ss 0))))
     (repeat (setq i (sslength ss))
       (setq sname (ssname ss (setq i (1- i))))
       (setq p1 (cdr (assoc 10 (entget sname))))
       (entmakex (list '(0 . "LINE") p (cons 11 p1)))
     )
   )
   (princ)
 )
 (princ)
)

 

Tharwat

Posted
To get the best result as you are looking for , select the base point first and after that the rest of points . :)

 

Thank you. All the best!

Posted (edited)

Another idea:

 

DrawLines.gif

 

(defun c:test ( / a b g i l p s u )
   (if (setq s (ssget '((0 . "POINT"))))
       (progn
           (repeat (setq i (sslength s))
               (setq p (assoc 10 (entget (ssname s (setq i (1- i)))))
                     u (cons (trans (cdr p) 0 1) u)
                     l (cons p l)
               )
           )
           (princ "\nSelect Point: ")
           (while
               (progn (setq g (grread t 13 2) a (car g) b (cadr g))
                   (cond
                       (   (= 5 a) (redraw)
                           (foreach x u (grdraw x b 1 1)) t
                       )
                       (   (= 3 a)
                           (if (setq s (ssget b '((0 . "POINT"))))
                               (progn
                                   (setq p (cdr (assoc 10 (entget (ssname s 0)))))
                                   (foreach x l (entmakex (list (cons 0 "LINE") x (cons 11 p)))) nil
                               )
                               (princ "\nPlease Select a Point.")
                           )
                       )
                   )
               )
           )
       )
   )
   (redraw) (princ)
)

Edited by Lee Mac
Posted
Another idea:...

 

Ideas are worth a dime dozen, but people who put them into action are priceless. (African proberb)

 

Lee Mac - Thank you!

Posted
Ideas are worth a dime dozen, but people who put them into action are priceless. (African proberb)

 

A very thoughtful quotation advex, I like it. :)

 

Lee Mac - Thank you!

 

Cheers :beer:

Posted

Lee,

It is possible to replace points with blocks?

Select blocks (points with attributes) and the same functionality .... ?!?! :cry::cry:

Posted
Lee,

It is possible to replace points with blocks?

Select blocks (points with attributes) and the same functionality .... ?!?! :cry::cry:

 

Certainly! In my code, replace the word "POINT" with "INSERT" (in two places), change the prompts, and all should still work ;)

Posted
Certainly! In my code, replace the word "POINT" with "INSERT" (in two places), change the prompts, and all should still work ;)

 

Thanks again! Your applications made ​​my life easier... :)

 

coffee.gif [from www.millan.net]

Posted
Thanks again! Your applications made ​​my life easier... :)

 

Good stuff advex! :D

Posted (edited)

Here is another one, based on points distances... You select first one, and routine connect them based on closest next point :

 

(defun pointsarray ( ptst ptl / dptpt dptptlst mindptpt pten ptl )
 (foreach pt ptl
   (setq dptpt (distance ptst pt))
   (setq dptptlst (cons dptpt dptptlst))
 )
 (setq dptptlst (vl-remove 0.0 dptptlst))
 (setq mindptpt (eval (cons 'min dptptlst)))
 (mapcar '(lambda (pt) (if (= (distance ptst pt) mindptpt) (setq pten pt))) ptl)
 (setq ptlst (cons ptst ptlst))
 (setq ptl (vl-remove ptst ptl))
 (if (not (null ptl)) (pointsarray pten ptl) ) 
 ptlst
)

(defun c:pts2lines ( / ss ssn pt ptl ptst ptlst )
 (prompt "\nSelect points that you want to connect with lines")
 (setq ss (ssget '((0 . "POINT") (210 0.0 0.0 1.0)) ))
 (setq ssn (sslength ss) i ssn)
 (repeat ssn
   (setq pt (cdr (assoc 10 (entget (ssname ss (setq i (1- i)))))))
   (setq ptl (cons pt ptl))
 )
 (setq ptl (reverse ptl))
 (vl-cmdf "_.OSNAP" "node")
 (setq ptst (getpoint "\nPick start point from witch to create continous array of lines obtained from rest of selected points"))
 (setq ptlst (pointsarray ptst ptl))
 (vl-cmdf "_.LINE")
 (foreach pt ptlst
   (vl-cmdf pt)
 )
 (vl-cmdf "")
(princ)
)

 

M.R.

 

BTW. If you want to draw polyline, just replace (vl-cmdf "_.LINE") with (vl-cmdf "_.PLINE")

Edited by marko_ribar
BTW...
Posted
Here is another one, based on points distances... You select first one, and routine connect them based on closest next point...

 

Thanks for posting the application but the algorithm is different. Add to collection!

Posted

It would be interesting that the lines were drawn in all possible combinations in selected points but with the criterion of triangulation, an example of MDT. It means that the crossing lines've not be considered. Better yet, would be able to choose the option to trade triangles, but it would be a program topography.

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