I need to know if an object is inside or outside a block.

I need to know if an object is inside or outside a block.

carlos_m_gil_p
Advocate Advocate
986 Views
4 Replies
Message 1 of 5

I need to know if an object is inside or outside a block.

carlos_m_gil_p
Advocate
Advocate

Hello boys how are you.

I have a question, to see if you can give me a hand with this.

 

I need to know if an object is inside or outside a block.
I am currently obtaining the properties of the following way.
(dumpAllProperties (car (entsel)) 1)
And if I need something specific I use it in the following way.
(getpropertyvalue (car (entsel)) "LocalizedName")

There is the possibility of knowing with these functions that I am using, if an object is inside a block or outside the block.
Is that when I'm editing a block with refedit and I need to select all the points that are inside the block to delete them, it works fine, but in the same way if there are points that are outside the block, these are also deleted and so it does not work.

 

Beforehand thank you very much.
Excuse my English, I only speak Spanish.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
987 Views
4 Replies
Replies (4)
Message 2 of 5

ronjonp
Mentor
Mentor

Perhaps something like this:

(defun c:foo (/ a d)
  ;; RJP » 2018-10-02
  ;; Delete all points within blocks
  (setq d (vla-get-activedocument (vlax-get-acad-object)))
  (vlax-for l (vla-get-layers d)
    (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  )
  (vlax-for b (vla-get-blocks d)
    (if	(= 0 (vlax-get b 'isxref) (vlax-get b 'islayout))
      (vlax-for	o b
	(cond ((vlax-write-enabled-p o)
	       (cond ((wcmatch (vla-get-objectname o) "AcDbPoint") (vla-delete o)))
	      )
	)
      )
    )
  )
  (foreach l a (vlax-put l 'lock -1))
  (vla-regen d acallviewports)
  (princ)
)
(vl-load-com)
Message 3 of 5

carlos_m_gil_p
Advocate
Advocate

Hi rperez.

It works well.
But I do not need to erase it in all the blocks.
Only in the one that is editing.
Another question.
There is some way to know which points are in the block with the function (dumpAllProperties (car (entsel)) 1)

Thank you.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 4 of 5

cadffm
Consultant
Consultant

I am away from Acad, but if you set your refedit setting well (lock option) and using the erase command, it should working.

 

My question is: Are you using refedit only for this step?

Then this is the wrong way and the code above should be a better solution.

But you need a blocknamefilter, sure.

 

If you do other things too in the refedit session i would use the lock option(alwas?) and the normal erase command,

i think you used this way before, but your lock option in refedit setting is disabled.

 

 

 

Sebastian

0 Likes
Message 5 of 5

carlos_m_gil_p
Advocate
Advocate

Hello how are you

I am currently using it in the following way.

 

(defun c:xxx  (/ all cont ent-uni i)
  ;;
  (setq all (ssget "_X"))
  (setq i -1)
  (setq cont 0)
  (while (setq ent-uni (ssname all (setq i (1+ i))))
    (if	(member (getpropertyvalue ent-uni "LocalizedName") (list "Point"))
      (progn (setq cont (1+ cont)) (entdel ent-uni))))
  ;;
  )

In this example they are points, but they can be lines or other objects.

When they are a lot of objects, the dumpAllProperties function is the fastest.
I want to know if there was any way to know what was inside or outside the block that I am editing. With the dumpAllProperties function

Thanks.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes