Author Topic: Insertionpoint of complex object WITHOUT using nentsel  (Read 7360 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #15 on: December 07, 2009, 01:34:41 PM »
Just playing "What If" in my head, plenty of spare room in there. :evil:

Condition 1
What if you want to replace a block A which has block C within it.
The New block B has block D within it. But block D does not exist in the DWG.

Condition 2
What if you want to replace a block A which has block C within it.
New block B has a different block C within it.
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.

ArgV

  • Guest
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #16 on: December 07, 2009, 06:19:03 PM »
Ok, so you want to redefine a block ... lets call it block "A" ... to do this, you want to get the insertion point of block "A" so you can put the new block in its place. Great .. now we are getting somewhere ... except you can't do that using a block from the blocks collection .. that is merely the definition of a block ...

To use an insertion point, you have to have an "INSERT" .. which is a BlockReference, you have a "BLKDEF" i.e. Block ...

You have a few options:
A) Select all of the inserted blocks in the drawing, either through an iteration of every element in the drawing, or by opening the drawing and using a select call to find them all, then get the insertion point of each INSERT and put your new INSERT there.

OR

B) Take the block definition (from the Blocks Collection) and delete all objects in it .. then add the items you want to that block definition.

OR

C) Insert the redefined BLOCK from a file, causing the definition to be overwritten.

I'm just realizing how very little I know about how autocad actually uses and handles blocks.

A block is nothing more than a selection set that has been, uh, 'glued' together so to speak. right? So, what I think I'm hearing is that if this block I want to replace was not "inserted" but rather was formed from within the drawing, it would not have an insertionpoint, however ALL blocks have a point at which they are inserted.

I don't know, now I'm really confused. I appreciate the help, but it's not penetrating the thickness of my skull.

ArgV

  • Guest
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #17 on: December 07, 2009, 06:21:25 PM »
When I posted, I was under the impression that you wanted to modify the nested block within the BLOCK definition in some way, but it now appears that you want to replace the INSERT in the drawing, at each occurrence.

As Keith points out, this can be done using a SelectionSet, or Iterating through the objects in the drawing, or if the new block is defined in the block table, then you can just substitute the name of the new block for the old in the INSERT.

Lee

The new block does not reside in the drawing currently. They were "fixed" outside the drawing, and now the old ones need to be swapped out with the new ones, which is why I have to INSERT them, rather than just update them. (which I'm foggy on that one as well).


ArgV

  • Guest
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #18 on: December 07, 2009, 06:23:51 PM »
One more point ArgV,

You can check the available properties/methods that are applicable to an object, using either:

Code: [Select]
(vlax-dump-object <obj> t)

Or

Code: [Select]
(vlax-property-available-p <obj> 'Property)

(vlax-method-applicable-p <obj> 'Method)

And hence you will correctly find that the BLOCK Definition does not have the InsertionPoint property  :wink:

Lee

Yep, I got that one figured out. :) So, then, what I can't figure out is why, and what I can do to get around it. I'm getting lots of ideas, but just not able to get my mind around them. Thank you for help though. I need a deeper understanding of the autcad database and how it works I guess.

ArgV

  • Guest
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #19 on: December 07, 2009, 06:25:46 PM »
I would go with option B from Keith's post.

Edit: Especially if you want to go the ObjectDBX route.

Edit:  Maybe this post will give you the general idea of one way to do it.
[ http://www.theswamp.org/index.php?topic=23128.0 ]

which version? It looks like there are 3 posts there with different approaches. I can't use entsel obviously, I'm stuck doing it all programically. Hey, is it ok to use selection sets in objectDBX? I'm not sure, or don't remember.

I'll give those a look tonight while I'm drinkin my Gin and juice and racking my brain. ;)

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #20 on: December 07, 2009, 06:26:15 PM »
When present in (but not necessarily inserted into) a drawing, Blocks are defined in the Block Collection, and all the elements that make up a block (i.e. lines, circles, attdefs, etc) are a member of that definition, just as lines and circles in a drawing are a member of the Paperspace or Modelspace "block".

The block as defined in the Block Collection does not have an insertion point, as it is just a definition and is separate from ModelSpace and/or PaperSpace in which entities have Insertion Points. You can think of the block definition as another PaperSpace/ModelSpace in which the objects are defined.

When you insert a block, you are inserting a reference to the definition that is contained in the Block Collection - as if you were viewing the block collection through a Viewport might be an analogy. And now that this object is part of PaperSpace/ModelSpace it has an insertionpoint and rotation etc, just as you are likely to find for any other object.

I hope I haven't just confused the hell out of you, but if others believe my explanation to be erroneous, please chime in - I would want to be corrected if I am mistaken for the sake of my own knowledge of such things...

Lee
« Last Edit: December 07, 2009, 06:49:56 PM by Lee Mac »

ArgV

  • Guest
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #21 on: December 07, 2009, 06:29:09 PM »
When present in a drawing, Blocks are defined in the Block Collection, and all the elements that make up a block (i.e. lines, circles, attdefs, etc) are a member of that definition, just as lines and circles in a drawing are a member of the paperspace or modelspace "block".

The block as defined in the Block Collection does not have an insertion point, as it is just a definition and is separate from ModelSpace and/or PaperSpace in which entities have insertion Points. You can think of the block definition as another PaperSpace/ModelSpace in which the objects are defined.

When you insert a block, you are inserting a reference to the definition that is contained in the Block Collection - as if you were viewing the block collection through a Viewport might be an analogy. And now that this object is part of PaperSpace/ModelSpace it has an insertionpoint and rotation etc, just as you are likely to find for any other object.

I hope I haven't just confused the hell out of you, but if others believe my explanation to be erroneous, please chime in - I would want to be corrected if I am mistaken for the sake of my own knowledge of such things...

Lee

Ok, I think I can get that much. What I don't understand I guess, is why I would have a block or HOW you can get a block that doesn't have an insertion point? Is it because it's never been inserted?

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #22 on: December 07, 2009, 06:31:04 PM »
The new block does not reside in the drawing currently. They were "fixed" outside the drawing, and now the old ones need to be swapped out with the new ones, which is why I have to INSERT them, rather than just update them. (which I'm foggy on that one as well).

Say you have Block A inserted in the drawing, and you want to replace it with Block B (which is also defined in the drawing - i.e. contained in the block collection, but not necessarily inserted).

Then this should successfully "swap" the blocks:

Code: [Select]
(defun c:test (/ nblk ent )

  (setq nblk "test") ;; Replacement Block

  (if (tblsearch "BLOCK" nblk)
   
    (if (and (setq ent (car (entsel "\nSelect Block to be Replaced: ")))
             (eq "INSERT" (cdr (assoc 0 (entget ent)))))
     
      (entmod (subst (cons 2 nblk) (assoc 2 (entget ent)) (entget ent))))
   
    (princ "\n** Replacement Block must be defined in the drawing **"))

  (princ))
« Last Edit: December 07, 2009, 06:35:06 PM by Lee Mac »

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #23 on: December 07, 2009, 06:32:26 PM »
When present in a drawing, Blocks are defined in the Block Collection, and all the elements that make up a block (i.e. lines, circles, attdefs, etc) are a member of that definition, just as lines and circles in a drawing are a member of the paperspace or modelspace "block".

The block as defined in the Block Collection does not have an insertion point, as it is just a definition and is separate from ModelSpace and/or PaperSpace in which entities have insertion Points. You can think of the block definition as another PaperSpace/ModelSpace in which the objects are defined.

When you insert a block, you are inserting a reference to the definition that is contained in the Block Collection - as if you were viewing the block collection through a Viewport might be an analogy. And now that this object is part of PaperSpace/ModelSpace it has an insertionpoint and rotation etc, just as you are likely to find for any other object.

I hope I haven't just confused the hell out of you, but if others believe my explanation to be erroneous, please chime in - I would want to be corrected if I am mistaken for the sake of my own knowledge of such things...

Lee

Ok, I think I can get that much. What I don't understand I guess, is why I would have a block or HOW you can get a block that doesn't have an insertion point? Is it because it's never been inserted?

A block may be present in the Block Collection, but not in the drawing itself (thats what purge was invented for.. lol), try it - insert a block, then delete it. Then check the table.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Insertionpoint of complex object WITHOUT using nentsel
« Reply #24 on: December 07, 2009, 06:44:51 PM »
I would go with option B from Keith's post.

Edit: Especially if you want to go the ObjectDBX route.

Edit:  Maybe this post will give you the general idea of one way to do it.
[ http://www.theswamp.org/index.php?topic=23128.0 ]

which version? It looks like there are 3 posts there with different approaches. I can't use entsel obviously, I'm stuck doing it all programically. Hey, is it ok to use selection sets in objectDBX? I'm not sure, or don't remember.

I'll give those a look tonight while I'm drinkin my Gin and juice and racking my brain. ;)

You can use any of them, but just note that the last one will change the nested blocks definition also, not just the main block.  These all work on some type of selection, so they will have to be changed in that aspect, but they should give you a good idea of how to do what you want to do.  No selection sets with drawings opened with ObjectDBX.

I think there is just confusion on the naming of objects:

Block = block definition
Insert = inserted block definition

Maybe this will help clear up some confusion with the help people are trying to provide.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.