Author Topic: Getting Blocks with nEntselp?  (Read 2834 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Getting Blocks with nEntselp?
« on: July 06, 2009, 10:20:06 AM »
This may be an obvious question, but, whilst in a grread loop, is there any [quick] way to get a block from an (nentselp [pt]) selection?

Thanks,

Lee

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Getting Blocks with nEntselp?
« Reply #1 on: July 06, 2009, 11:07:12 AM »
well, it is possible ...

nentselp returns a matrix with the entity at the point and the block entity as the last item in the list IF it is a block. If it is a simple entity, it will not return the name ...

In this simple example, I return the object at the point ... obviously more error checking will need to be done:

Code: [Select]
(defun getblname (/ grvals gcode gval myent)
;;; infinite grread loop with cursor tracking
  (while (setq grvals (grread T))
    (setq gcode (car grvals) ; get the interface
  gval (cadr grvals)) ; and associated data
    (if (= gcode 5) ; if it is a tracked point
;;; get the entity there, or junk if it isn't a block
;;; error checking needed here
      (setq myent (caar (reverse (nentselp gval))))
    )
  )
)

Hope you can make use of it
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Getting Blocks with nEntselp?
« Reply #2 on: July 06, 2009, 11:26:01 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Getting Blocks with nEntselp?
« Reply #3 on: July 06, 2009, 11:35:32 AM »
Lee,
You did not specify if the user was to PICK the object or pass the cursor over the object for detection.

I assume Keith's example gave you what you needed?  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Getting Blocks with nEntselp?
« Reply #4 on: July 06, 2009, 11:38:51 AM »
Hi,

You can have a look at gc:AreaGet routine in TotalArea_4.02.lsp.
This routine is used to get a "ToatalArea" bloc reference. It highlights the objets which are linked to block the cursor is over.
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Getting Blocks with nEntselp?
« Reply #5 on: July 06, 2009, 06:21:27 PM »
Sorry for the late reply guys,

Keith, that is a great example.

I don't full understand the transformation matrix as, most of the time, nentselp seems to return a list identical to as if the user had used entsel, but after experimenting on a block, I see a whole matrix, with the entity names you mention.

> Gile

Thanks, I had a quick look at your routine as I knew that you would have had to use something to overcome this - but I didn't immediately see your method  :oops:

> CAB

Thanks for the link - nice example. The entity would be picked, but I believe I can use Keith's method either way.

Thanks once again for your time guys,

Lee

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Getting Blocks with nEntselp?
« Reply #6 on: July 07, 2009, 12:09:06 AM »
The example I provided will do hot tracking of entitites by simply moving the mouse over them. I have used this in the past for dynamic displaying of entity data without having to select them. This way the user could see object properties with ease.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Getting Blocks with nEntselp?
« Reply #7 on: July 07, 2009, 08:54:00 AM »