Base point block

Discussion in 'AutoCAD' started by StefVdM, Jun 11, 2004.

  1. StefVdM

    StefVdM Guest

    Hi,

    I was wondering: is there a way to retrieve/change the base point of a "simple" block? First I thought "vla-get-Origin" or "vla-put-Origin" would do the trick, but then I discovered that the "origin"-property was not available for the blocks I selected.

    Thanks for any help,

    Stef
     
    StefVdM, Jun 11, 2004
    #1
  2. StefVdM

    Doug Broad Guest

    A block has an origin.

    A block-reference has an insertionpoint.

    AFAIK
    If the block was created with the block command,
    it should have an origin of (0.0 0.0 0.0)

    The only time I have seen the origin differ from
    '(0.0 0.0 0.0) is for an xref attachment that had
    an insbase or base set to something different.



    "vla-put-Origin" would do the trick, but then I discovered that the "origin"-property was not available for the blocks I selected.
     
    Doug Broad, Jun 11, 2004
    #2
  3. Agreed, and that's an important distinction. You can extract the insertion
    point of a block from its association list / dxf codes. But I don't think
    you can extract the relationship between that and the entities that make up
    the block. And I don't think you can change that relationship by way of
    association values. You can change the value of the insertion point of a
    block reference, which would MOVE the block in the drawing, but wouldn't
    change the defined origin base point in relation to its pieces.
    ONLY if you accept that as the offered default base point in the Block
    dialog box. There's a "Pick point" button to set an insertion base point
    that makes some sense in relation to the pieces. 0,0,0 is a pretty useless
    origin point for most blocks made of elements drawn at some
    out-in-the-drawing location, as I suspect most blocks are. Leaving it at
    0,0,0 instead means (in almost all cases) you most likely won't be able to
    drag the block visually into place when you insert it.
    I don't EVER leave a block's (or a Wblocked drawing's) insertion point at
    0,0,0 unless it's something like a sheet border and title block drawing, or
    maybe if I'm in some temporary drawing only for the purpose of making things
    and Wblocking them out, so I might build them deliberately around 0,0,0.
    What good is an insertion base point if it doesn't have some logical
    relationship to the elements in it (like the center of a circular tree
    block, or the midpoint of the wall side of a bathroom lavatory)?

    Even when you make a new drawing with Wblock, if you select a logical
    location for its insertion base point, that location does NOT become 0,0,0
    in the new drawing. It remains where it was in the drawing out of which you
    Wblocked it. It is saved as the variable INSBASE.
    "simple" block? First I thought "vla-get-Origin" or
    "origin"-property was not available for the blocks I selected.

    I haven't found any way to change the origin point of a block definition in
    Refedit or anything. I think you might have to explode the block and
    redefine it with a new insertion base point. Or in Refedit, you COULD
    record the insertion point, then select all the elements of the block and
    move them to a different position in relation to that point, then save the
    changed block definition.

    Kent Cooper, AIA
     
    Kent Cooper, AIA, Jun 11, 2004
    #3
  4. StefVdM

    Doug Broad Guest

    Hi Kent. See below.

    [db]The block reference has no entities of its own. To translate coordinates
    between the block reference and the block definition, use the trans function
    or its activeX equivalent.
    [db]NOT true. Before posting, I created a block and chose the insertion
    point at (2,2,0). After inserting the block, I examined the origin
    property of its block definition. It was 0,0,0. The block command
    does the translation during the block creation process.
    [db] I always try to avoid using insbase and base to control a drawings's
    insertion point because it *ALWAYS* causes problems with trimming
    and extending otherwise (due to an ACAD bug present since trimming and
    extending with xref entities was made possible). Instead, I move
    all objects from where the insertbase would have been to 0,0,0. That
    practice has proved very satisfactory. Avoid the temptation to use insbase
    or base.

    [db] After Wblocking objects, I always open the drawing and use my IBA
    command to shift all objects from the insbase to 0,0 and set the insbase to 0,0.
    Otherwise, if the drawing is ever xrefed, instead of inserted, the trim and
    extend commands do not work.
    [db](vla-put-origin ...) will change the origin of the block. But wblocking
    and changing it in its own drawing would probably be more intuitive to most drafters.
     
    Doug Broad, Jun 11, 2004
    #4
  5. StefVdM

    Doug Broad Guest

    To add to my responses:
    In 2004, wblock creates a drawing with the insbase set to whatever
    origin the user picks during the wblock command.

    In 2005, wblock creates a drawing with insbase=0,0,0 and the blocks
    shifted so that the insertion point selected becomes the 0,0,0 point in
    the new drawing. This is probably Autodesk's response to the xref
    trim/extend problem.

    I am not sure about earlier versions and their block/wblock behavior.
    It would be prudent to test each version before making other
    assumptions.

    Regards,
    Doug


    <snip>
     
    Doug Broad, Jun 11, 2004
    #5
  6. StefVdM

    StefVdM Guest

    O yes, right. Keeping the distinction between a "block" and a "block-reference" in mind, then my original question should have been: is it possible to change the origin of a block. And by that I hoped there would be a solution without exploding and redefining the block. You know, I just hoped Vlisp or VBA would have a function to directly access the origin as a property or something.

    But apparently that is not the case. Ken, now you've given me some new food for thought: how to use "refedit" through code. I'm sure you guys know how to do that, but please don't tell the answer. I'd like to try to find out myself first.

    Thanks for the help!

    Stef
     
    StefVdM, Jun 14, 2004
    #6
  7. StefVdM

    Joe Burke Guest

    Stef,

    You can do it like this. There's no provision here to modify the Z value, though
    easily added. And I don't know what method you had in mind for specifying the new
    origin point. For instance you might ask for distance and angle.

    I appreciate why you might want to do it. Sometimes we have a drawing used only to
    create lots of blocks. An insertion (origin) point might need to move. I'd rather not
    explode just to do that. The fact the block reference would move is of no concern in
    this drawing.

    Joe Burke

    ;; modify a block definition origin (insertion) point
    ;; note: existing block references will move
    (defun c:BlockModInspt ( / doc blocks blk nm org xoff yoff )
    (and
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (setq blocks (vla-get-blocks doc))
    (setq blk (vlax-ename->vla-object
    (car (entsel "\nSelect block: "))))
    (setq nm (vlax-get blk 'Name))
    (setq blk (vla-item blocks nm))
    (setq org (vlax-get blk 'Origin))
    (princ (strcat "\nExisting origin: " (vl-princ-to-string org)))
    (setq xoff (getdist "\nEnter X axis offset "))
    (setq org (mapcar '+ (list xoff 0 0) org))
    (setq yoff (getdist "\nEnter Y axis offset "))
    (setq org (mapcar '+ (list 0 yoff 0) org))
    (not (vlax-put blk 'Origin org))
    (not (vla-regen doc acActiveViewport))
    (princ (strcat "\nNew origin: "
    (vl-princ-to-string (vlax-get blk 'Origin))))
    )
    (princ)
    )

    mind, then my original question should have been: is it possible to change the origin
    of a block. And by that I hoped there would be a solution without exploding and
    redefining the block. You know, I just hoped Vlisp or VBA would have a function to
    directly access the origin as a property or something.
    thought: how to use "refedit" through code. I'm sure you guys know how to do that,
    but please don't tell the answer. I'd like to try to find out myself first.
     
    Joe Burke, Jun 14, 2004
    #7
  8. StefVdM

    StefVdM Guest

    Joe,

    Thanks for the code! With some changes it seems like this will do what I had in mind. "Some changes", because I intended just to ask for the new origin point.

    Why I wanted to do all this: sometimes I "clone" existing block-references, in order to create a new similar block with some changes. But, if I edit the clone, the origin stays where it was in the original, although it does not necessarily relate to the newly edited entities any more. It might, for instance, suddenly fall somewhere outside the block.

    thanks again!

    Stef
     
    StefVdM, Jun 14, 2004
    #8
  9. StefVdM

    Joe Burke Guest

    Stef,

    You're welcome.

    If you intend to ask for a point (getpoint) to define the new origin, keep in mind a
    block definition has its own coordinate system. Usually referred to as the OCS of the
    block.

    So to make this work right you might do this. Move the block reference so its
    insertion point is at 0,0,0. Make sure you are in WCS because getpoint returns a UCS
    point. Then use what I posted to change the X , Y and Z origin values based on what
    getpoint returns. That will result in a block definition with an insertion point
    that's not (0.0 0.0 0.0). Not typical, but I don't think it would cause any problems.

    Another way would be to translate the point returned by getpoint to the OCS of the
    block. That can get pretty complicated. You wouldn't have to move the block to 0,0,0.
    But you would need a function which returns an inverse matrix (inverse of what
    nentselp returns given a block reference) and another function which translates the
    point based on the inverse matrix.

    John Uhden has posted functions which do these things. But I don't see any reason to
    get into that stuff if you find the first method I suggested works OK.

    Let us know how it goes.

    Joe Burke

    mind. "Some changes", because I intended just to ask for the new origin point.
    order to create a new similar block with some changes. But, if I edit the clone, the
    origin stays where it was in the original, although it does not necessarily relate to
    the newly edited entities any more. It might, for instance, suddenly fall somewhere
    outside the block.
     
    Joe Burke, Jun 14, 2004
    #9
  10. StefVdM

    MBCAD Guest

    Stef,

    Can you post your new code? I would like to change the block insertion point of a block I have inserted in various locations in a drawing.
     
    MBCAD, Jun 18, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.