Author Topic: "simulate" pick point  (Read 3502 times)

0 Members and 1 Guest are viewing this topic.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
"simulate" pick point
« on: November 06, 2008, 03:31:13 AM »
Is there a way to feed a point (variable) to simulate clicking on an object to select it?

DJE
===
dJE

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: "simulate" pick point
« Reply #1 on: November 06, 2008, 04:33:27 AM »
yes,
say
( setq yourPoint '(0 0 0))

try (setq ent (car (nentselp yourPoint)))

OR
Have a look at ssget

using either the point  ie
 (ssname (ssget yourPoint ) 0)
OR
with a crossing
 (ssname (ssget "_C" '(0 0) '(1 1)) 0)

OR
try (setq ent (car (nentselp yourPoint)))




« Last Edit: November 06, 2008, 04:55:54 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: "simulate" pick point
« Reply #2 on: November 06, 2008, 08:10:18 AM »
nentselp sounds the way to go :)

I'll have a play with that and let you know how I get on.
===
dJE

cjw

  • Guest
Re: "simulate" pick point
« Reply #3 on: November 06, 2008, 07:55:11 PM »
Very nice!
Just search for it.
It's not accurate code I use before:

(setq ent (entsel "\nget the point:"))
(setq e  (car ent)
        pt (cadr ent)
        pt (vlax-curve-getclosestpointto e pt)
)
« Last Edit: November 06, 2008, 08:04:32 PM by cjw »

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: "simulate" pick point
« Reply #4 on: November 07, 2008, 03:48:16 AM »
Experimenting with NENTSELP, this is my code:
(DEFUN c:obj ( / )
   (SETQ
      select (ENTSEL "\nSelect object: ")
      ent (CAR select)
      hpt (CDR select)
   )
   (PRINC "\nent: ")(PRINC ent)
   (PMAKE)
   (SETQ ent2 (CAR(NENTSELP hpt)))
   (PRINC "\nent2: ")(PRINC ent2)
)

(defun pmake () (command "PEDIT" ent "YES" "" "")(princ))

But I only ever get an error message:
error: bad argument type: 2D/3D point: ((142.318 200.826 0.0))

Any ideas?

DJE
===
dJE

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: "simulate" pick point
« Reply #5 on: November 07, 2008, 04:19:26 AM »
Dan,
what do you think that code should be doing ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: "simulate" pick point
« Reply #6 on: November 07, 2008, 08:33:00 AM »
It's a test routine

Select an object, saving as a variable
split out the entity itself and the selection point into two other variables
Print the entity name to the command line
Turn the entity into a polyline
Select the entity at the original coordinates
Print the new entity name to screen

DJE
===
dJE

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: "simulate" pick point
« Reply #7 on: November 07, 2008, 09:03:02 AM »
Figured it out :)

I need to set hpt to (CAR(CDR select)) not just (CDR select)!!  That can be shortened to (CADR select) can't it?

DJE (in glory!)
===
dJE

Alan Cullen

  • Guest
Re: "simulate" pick point
« Reply #8 on: November 07, 2008, 09:07:51 AM »
I believe so....I'm a bit sloppy at the moment.....
but (CAR(CDR select)) = (CADR select)

Too lazy to check my notes at the moment. (getting too drunk...well it IS Friday night)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: "simulate" pick point
« Reply #9 on: November 07, 2008, 10:38:45 AM »
Maybe some food for thought:

Code: [Select]
(defun c:obj (/ ent ent2 hpt select)
  (if (and (setq select (entsel "\nselect object: "))
   (setq ent (car select))
   (setq hpt (cadr select))
   (not (wcmatch (cdr (assoc 0 (entget ent))) "*POLYLINE"))
      )
    (progn
      (pmake ent)
      (setq ent2 (entlast))
      (princ (strcat "\nent: "
     (vl-princ-to-string ent)
     "  ent2: "
     (vl-princ-to-string ent2)
     )
      )
    )
    (princ
      "\nYou either missed your pick or the object was already a polyline!"
    )
  )
)

(defun pmake (ent)
  (command "pedit" ent "yes" "" "")
)


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: "simulate" pick point
« Reply #10 on: November 07, 2008, 08:07:55 PM »
Figured it out :)
<<


great !

<<
I need to set hpt to (CAR(CDR select)) not just (CDR select)!!  That can be shortened to (CADR select) can't it?
>>

Yes
here are enough cars to start a sales yard .. :)

Code: [Select]
(car theList) Returns the first element of a theList.
(cdr theList) Returns the theList minus the first element.
(caar theList) The car of the car of theList
(cadr theList) The car of the cdr of theList
(cdar theList) The cdr of the car of theList
(cddr theList) The cdr of the cdr of theList
(caaar theList) The car of the car of the car of theList
(caadr theList) The car of the car of the cdr of theList
(cadar theList) The car of the cdr of the car of theList
(caddr theList) The car of the cdr of the cdr of theList
(cdaar theList) The cdr of the car of the car of theList
(cdadr theList) The cdr of the car of the cdr of theList
(cddar theList) The cdr of the cdr of the car of theList
(cdddr theList) The cdr of the cdr of the cdr of theList
(caaaar theList) The car of the car of the car of the car of theList
(caaadr theList) The car of the car of the car of the cdr of theList
(caadar theList) The car of the car of the cdr of the car of theList
(caaddr theList) The car of the car of the cdr of the cdr of theList
(cadaar theList) The car of the cdr of the car of the car of theList
(cadadr theList) The car of the cdr of the car of the cdr of theList
(caddar theList) The car of the cdr of the cdr of the car of theList
(cadddr theList) The car of the cdr of the cdr of the cdr of theList
(cdaaar theList) The cdr of the car of the car of the car of theList
(cdaadr theList) The cdr of the car of the car of the cdr of theList
(cdadar theList) The cdr of the car of the cdr of the car of theList
(cdaddr theList) The cdr of the car of the cdr of the cdr of theList
(cddaar theList) The cdr of the cdr of the car of the car of theList
(cddadr theList) The cdr of the cdr of the car of the cdr of theList
(cdddar theList) The cdr of the cdr of the cdr of the car of theList
(cddddr theList) The cdr of the cdr of the cdr of the cdr of theList
so ..
(caar theList)  is equivalent to (car (car theList))
(cdar theList)  is equivalent to (cdr (car theList))
(cadar theList) is equivalent to (car (cdr (car theList)))
(cadr theList)  is equivalent to (car (cdr theList))
(cddr theList)  is equivalent to (cdr (cdr theList))
(caddr theList) is equivalent to (car (cdr (cdr theList)))
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.