Jump to content

Mulitple Lines


j_spawn_h

Recommended Posts

Can someone help me. If i select multiple lines by using ssget. How can I get it to know which line is the first and last line of the selection? Is there a lisp already doing this? I have the code to detect the points just need to know the code to determine the first and last.

Link to comment
Share on other sites

Thanks Tharwat. This did what I asked but it seems I am not as good as I thought. I could not find the mid point of the first line. Could you give a suggestion or help here. Here is what I tried to do.

 

(defun c:matt (/)
 (setq ss (ssget "_:L" '((0 . "LINE"))))

 (setq first-line (ssname ss 0))
 (setq last-line (ssname ss (1- (sslength ss))))
(command "select" last-line "")
 (setq ed (entget en))
           (setq p10 (cdr (assoc 10 ed)))
           (setq p11 (cdr (assoc 11 ed)))
           (setq mpt (mapcar '(lambda (a b) (* (+ a b) 0.5)) p10 p11))
           (setq d2d (distance (cdr (reverse p10)) (cdr (reverse p11))))
           (setq d1d (/ d2d 12.))

 (command "_dimlinear" last-line "-mid")


 )

Link to comment
Share on other sites

Thanks Tharwat. This did what I asked but it seems I am not as good as I thought. I could not find the mid point of the first line. Could you give a suggestion or help here. Here is what I tried to do.

 

You're welcome ..

 

Check this out ...

 

(if (setq ss (ssget '((0 . "LINE"))))
 (progn
   (setq first-line (ssname ss 0))
   (setq mid-point (mapcar '(lambda (q p) (/ (+ q p) 2.))
                           (cdr (assoc 10 (entget first-line)))
                           (cdr (assoc 11 (entget first-line)))
                   )
   )
 )
)

Link to comment
Share on other sites

Sorry to interfere, but (ssname (ssget "_X") 0) is equivalent to (entlast), so if you want last created object you can use index 0, and if you want first use : (- (sslength (ssget)) 1) as index in ssname function...

 

M.R.

Link to comment
Share on other sites

If i select multiple lines by using ssget. How can I get it to know which line is the first and last line of the selection?

 

If you window over a set of lines in a selection, what do you classify as being the 'first' & 'last' in the selection?

The line nearest the window edge?

The line with lowest/highest x/y/z coordinate?

The lines as they are ordered in the database?

 

When using a selection mode string other than scanning the entire database ("_X" mode), you cannot rely on the order of the entities in the selection set - the "_X" mode will retrieve entities in the order they appear in the drawing database, i.e. in the order they were created in the drawing.

Link to comment
Share on other sites

Nice answer Lee re database order, also remember last is actually first, pretty sure the selection set is created by pushing entities into the list so sometimes you need to use the reverse option to get what is actually number 0 in list (yes 0 not 1) makes it easier sometimes to not have to think backwards.

Link to comment
Share on other sites

That is a good point Lee, but right now it doesn't matter which one is first or last. Good to know if I need to set certain lines. Do any of y'all know a thread to read about changing dimension stuff in lisp.

Link to comment
Share on other sites

J_spawn_h probably best to start a new thread and elaborate more about the DIM stuff is it part of you line question ? Auto dimensioning ? if so post a dwg the dimensions in the image were done by only picking two points.

 

3dhouse.jpg

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