Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

want to select several objects and get srating and endpoint of each one

35 REPLIES 35
Reply
Message 1 of 36
cadking2k5
963 Views, 35 Replies

want to select several objects and get srating and endpoint of each one

I want to make it so that I can keep selecting several objects and get all the sratingpoints and endpoints of each one with (setq ent (entsel))

(Defun c:demo (/ ent)
(setq ent (entsel))
(princ)
)
35 REPLIES 35
Message 21 of 36
alanjt_
in reply to: Kent1Cooper

I must have missed it. With both of us saying it, hopefully someone will see it. 

Message 22 of 36
BlackBox_
in reply to: Kent1Cooper


@Kent1Cooper wrote:

@alanjt_ wrote:

You can accomplish what you are doing with the normal extend and/or trim command. Just hold down the SHIFT key when selecting and it will toggle to trim, if in extend, and to extend if in trim.


[My last paragraph about that was an Edit addition, so I guess you replied to what it said before that went up.]


Perhaps this beith the problem. *not sure*



"How we think determines what we do, and what we do determines what we get."

Message 23 of 36
alanjt_
in reply to: BlackBox_

That, or I just didn't read every thing closely enough. 😕

Message 24 of 36
BlackBox_
in reply to: alanjt_

Well I am certainly not speaking for anyone other than myself... Just offering a polite observation.



"How we think determines what we do, and what we do determines what we get."

Message 25 of 36
alanjt_
in reply to: BlackBox_

It's all good, baby. 🙂

Message 26 of 36
cadking2k5
in reply to: Kent1Cooper

this only keep the end points of the last line I highlighted I need each endpoint of each line individal not in one and trim and extend will not do what I am trying to do it will only trim or exten if it crosses the line I am going to make it extend or time to that axis like in the front view you pick the bottom line  and in the right view you select lines it will exten them down to it or trim them up to it bottom line axis I know I don't have it all on here I have to get this to work first I have one that works with just one line

 

(defun c:see (/ *error* eName eNames)
(defun *error* (msg)
    (if eNames (foreach eName (mapcar 'car eNames) (redraw eName 4)))
    (cond ((not msg))                                                   ; Normal exit
          ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
          ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
    )
    (princ)
  )
  (while (setq eName (car (entsel "\nSelect an entity to highlight: ")))
    (setq ent (entget eName))
     (setq eNames (cons (list eName (list (cdr (assoc 10 ent)) (cdr (assoc 11 ent))))
                   eNames
             )
   )
     (redraw eName 3)
  )
;;		Do your thing here for " something like that" 	;;;
  	(foreach col eNames
          	(print col)
                )
  (*error* nil)
)
Message 27 of 36
alanjt_
in reply to: cadking2k5

Try this subroutine:

 

(defun _selectLines (msg / ent data lst)
  (while
    (progn
      (setvar 'ERRNO 0)
      (setq ent (car (entsel (cond (msg)
                                   ("\nSelect object: ")
                             )
                     )
                )
      )
      (cond
        ((eq (getvar 'ERRNO) 7) (princ "\nMissed, try again."))
        ((eq (type ent) 'ENAME)
         (if (eq (cdr (assoc 0 (setq data (entget ent)))) "LINE")
           (progn (redraw ent 3)
                  (setq lst (cons (list ent (cdr (assoc 10 data)) (cdr (assoc 11 data))) lst))
           )
           (princ "\nInvalid object!")
         )
        )
      )
    )
  )
  lst
)

 

Message 28 of 36
Kent1Cooper
in reply to: cadking2k5


@cadking2k5 wrote:

this only keep the end points of the last line I highlighted I need each endpoint of each line individal not in one and trim and extend will not do what I am trying to do it will only trim or exten if it crosses the line I am going to make it extend or time to that axis like in the front view you pick the bottom line  and in the right view you select lines it will exten them down to it or trim them up to it bottom line axis I know I don't have it all on here I have to get this to work first I have one that works with just one line


I'm afraid I have to go back to the last sentence in my first post [Message 14].

Kent Cooper, AIA
Message 29 of 36
alanjt_
in reply to: Kent1Cooper

I'm with Kent. This can be already be accomplished natively. 

Message 30 of 36
cadking2k5
in reply to: Kent1Cooper

highlighted means the one you select when you select objects they become highlighted isn't that what (redraw eName 3) dose

Message 31 of 36
alanjt_
in reply to: cadking2k5


@cadking2k5 wrote:

highlighted means the one you select when you select objects they become highlighted isn't that what (redraw eName 3) dose


Correct.

Message 32 of 36
Kent1Cooper
in reply to: cadking2k5


@cadking2k5 wrote:

... trim and extend will not do what I am trying to do it will only trim or exten if it crosses the line I am going to make it extend or time to that axis ....


[I assume the word 'time' above is meant to be 'trim'.]  Another possibility in those two commands that you may not be aware of is the Edge option, which can be set to Extend or No Extend.  If it is set to Extend, things to not need to cross, but will extend or trim to the extension of the selected boundary, or the virtual intersection, which I think will solve the issue quoted above.  You can do it inside either command by choosing that option, or you can set the EDGEMODE System Variable to 1 before you start.

Kent Cooper, AIA
Message 33 of 36
Kent1Cooper
in reply to: cadking2k5


@cadking2k5 wrote:

highlighted means the one you select when you select objects they become highlighted isn't that what (redraw eName 3) dose


If that's the issue, and, as some messages suggest, more than the last-selected item should be highlighted, it looks like the code in message 13 is doing something like that [as are later suggestions], but then doing nothing with the resulting list, nor with any of the Lines in it except to highlight them, so I'm not sure what the point of the highlighting is.  Should the (foreach) function that begins the second part be using that eNames list instead of the mysterious '(r), to extend or trim things to the whole set of first-part Lines?  But then it would be asking for selection of things to extend/trim in relation to individual Lines in the eNames list, in which case wouldn't you want only that one that's currently pertinent highlighted?  Or, if they want things extended or trimmed to that whole collection, shouldn't the things be put into a selection set rather than into a list, to feed to the object-selection prompt in the Extend or Trim command?  No, I guess not, because I don't think there would be a way to decide whether to extend or trim a given second-part object.  But then the code in Message 16 [and 18] asks the User to select an individual object as a boundary.  It's not highlighted, but it could be easily enough, but other messages sound like that's not what's wanted, since I think it would be only the one Line.  I'm still confused....

Kent Cooper, AIA
Message 34 of 36
cadking2k5
in reply to: Kent1Cooper

forget everything and start over I am trying to make it so I can select several lines at once and get each end point asigned to a ename like (setq startpoint and (setq endpoint of each line [so i can calulate the angles or distance from one end point to some where] of each line so I can extend an trim in one commad with out hold shift down or use it in some other command in the future some times the angle will be differant then the entsel like if it say it is 210 I might need 30

Message 35 of 36
Kent1Cooper
in reply to: cadking2k5


@cadking2k5 wrote:

... I am trying to make it so I can select several lines at once and get each end point asigned to a ename like (setq startpoint and (setq endpoint of each line [so i can calulate the angles or distance from one end point to some where] of each line so I can extend an trim in one commad with out hold shift down or use it in some other command in the future some times the angle will be differant then the entsel like if it say it is 210 I might need 30


[I think you must mean "assigned to a variable" rather than to an "ename."]  Are you looking for an individual variable name for every endpoint on the selected objects?  That can certainly be done, but I wonder how you would use them.  What kind of variable names would you want to use?

 

Or would it be better to tie them to the object they are the endpoints of, somehow?  In pbejse's first post here [Message 9], if you change the first line from

 

(defun c:see (/ *error* eName eNames)

 to

(defun c:see (/ *error* eName)

 

[that is, take eNames out of the localized variables list], run it, and select several Lines, it will result in a variable called eNames that contains a list of sublists, with each sublist containing a Line entity name and a list of its start- and endpoints.  Type !eNames to see the list.  Is that a way of organizing the points that would be useful to you?  If not, would a slight difference be better, such as removing the points from their paired lists and having each sublist be just (entity-name startpoint endpoint)?  Or something else?

 

Also, I would find it very much easier to read your messages with some punctuation in them.  It serves a real and useful purpose.  I saw a T-shirt recently that said:

 

Let's eat Grandma.

Let's eat, Grandma.

Punctuation saves lives!

Kent Cooper, AIA
Message 36 of 36
Kent1Cooper
in reply to: cadking2k5


@cadking2k5 wrote:

....I am trying to ... extend an trim in one commad with out hold shift down ....


Check out the combined Trim/Extend command [command name: TrimEx] here.  It uses a clever approach that would not have occurred to me -- after you select a boundary edge [or edges], for each selected object to Trim/Extend, it simply tries Trim on it and then tries Extend.  If it crosses a boundary, the Trim command works and [if there aren't multiple boundaries in the wrong kinds of places] the Extend command does nothing; if it doesn't cross, the Trim does nothing and the Extend works.  It has no limitation on entity types, beyond what's allowed in either basic command, and no points need to be calculated or saved to variables.  It lets you select multiple boundary edges, though in brief trial doing that, I find it can sometimes be a little unpredictable, depending on their geometric relationship, because some things might be trimmable to one boundary and extendable to another.  But in the kinds of things you want to do with it, that may not be a concern.  For the situation you have described in message 26, turn EDGEMODE on [1].  Try it out -- it may do what you're looking for.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost