backward attribs - vla-insertBlock

Discussion in 'AutoCAD' started by Jason Piercey, Jul 19, 2003.

  1. Is there some known problem with (vla-insertBlock)
    and mirrored attributes? I am trying to polish up a
    routine here and noticed if the selected attributed block
    is mirrored the newly created blocks attribs are backwards.


    ; mirrored attributed blocks are still a problem.
    (defun c:blockClone (/ ent new p1 ename data old obj)
    (setq *doc* (vla-get-activedocument (vlax-get-acad-object)))
    (while (not (setq ent (entsel "\nselect block to clone: "))))
    (while (= "" (setq new (getstring t "\nspecify new block name: "))))
    (initget 1) (setq p1 (getpoint "\nspecify insertion point: "))
    (setq ename (car ent))
    (setq data (entget ename))
    (setq old (cdr (assoc 2 data)))

    (cond
    ((cloneBlock old new)
    (setq
    obj
    (vla-insertblock
    (if (zerop (currentSpace))
    (vla-get-paperspace *doc*)
    (vla-get-modelspace *doc*)
    )
    (vlax-3d-point p1)
    new
    1 1 1 0
    )
    )
    (vla-put-xscalefactor obj (cdr (assoc 41 data)))
    (vla-put-yscalefactor obj (cdr (assoc 42 data)))
    (vla-put-zscalefactor obj (cdr (assoc 43 data)))
    (vla-put-rotation obj (cdr (assoc 50 data)))
    )
    (t (princ "\nunable to duplicate block"))
    )
    (princ)
    )


    ;(cloneBlock "atr-note" "test")
    (defun cloneBlock (old new / ename data lst)
    (and
    (tblsearch "block" old)
    (not (tblsearch "block" new))
    (setq ename (tblobjname "block" old))
    (setq data (entget ename))
    (setq data (subst (cons 2 new) (assoc 2 data) data))
    (setq lst (nEnts ename "*"))
    (setq data (cons data (mapcar 'entget lst)))
    (mapcar 'entmake data)
    (entmake '((0 . "ENDBLK")))
    )
    )

    ; Jason Piercey . June 2nd, 2003
    ; [ename] - entity name or vla-object - block, insert or polyline
    ; [filter] - string, re: wcmatch()
    ; return: list of enames or nil
    ; revised: July 10th, 2003 - accepts ename or vla-object
    (defun nEnts (ename filter / data ent rtn)
    (or (= 'ename (type ename))
    (setq ename (vlax-vla-object->ename ename)) )
    (setq filter (strcase filter))
    (while (and ename (setq ename (entnext ename)))
    (setq data (entget ename))
    (setq ent (cdr (assoc 0 data)))
    (if (wcmatch ent filter)
    (setq rtn (cons ename rtn)) )
    (if (= "SEQEND" ent) (setq ename nil))
    )
    (reverse rtn)
    )

    ; determine which space is active
    ; return: integer
    ; 1 - model space
    ; -1 - floating model space
    ; 0 - paper space
    (defun currentSpace (/ mode)
    (setq mode (getvar "tilemode"))
    (cond
    ((and (zerop mode) (<= 2 (getvar "cvport"))) -1)
    (t mode)
    )
    )
     
    Jason Piercey, Jul 19, 2003
    #1
  2. Jason Piercey

    David Bethel Guest

    What is your MIRRTEXT set to? -David
     
    David Bethel, Jul 19, 2003
    #2
  3. Jason Piercey

    Jeff Mishler Guest

    Jason,
    Check the value of the Attributes' Normal property.........
    Standard insert: Normal = (0.0 0.0 1.0)
    Mirrored Insert w/ Mirrtext = 0 :Normal = (0.0 0.0 1.0)
    Copy of Mirrored Insert using your clone code: Normal = (0.0 0.0 -1.0)

    Jeff
     
    Jeff Mishler, Jul 19, 2003
    #3
  4. Well.... if I obtain the selected inserts normal property and
    apply it to the newly created insert, the attribs are still
    backwards.
     
    Jason Piercey, Jul 20, 2003
    #4
  5. unless I have to aplly the normal property to the insert and
    each of the attribs....
     
    Jason Piercey, Jul 20, 2003
    #5
  6. Hmm.... doesn't seem to be it either
     
    Jason Piercey, Jul 20, 2003
    #6
  7. Jason Piercey

    Murph Guest

    Jason,
    I ran your code last night in R2002 and it worked ok, but tried it this
    morning on R2004 and get the backward text/attributes. Might this be a R2004
    issue?

    Murph
     
    Murph, Jul 21, 2003
    #7
  8. Jason Piercey

    Murph Guest

    May of posted too soon. Tried it again in R2002 here at the office and they
    are backwards. Must of been tried and confused last night at home, when I
    thought it was working in R2002.

    Murph

     
    Murph, Jul 21, 2003
    #8
  9. I am testing this in 2002..... Gotta be somethin' I'm missin'.
     
    Jason Piercey, Jul 21, 2003
    #9
  10. If you use vla- methods for retrieving the alignment point, you get them in
    WCS.

    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | ahh.... I see. Thanks Bob. Of course I will also need to
    | translate block to insert coords for the position of the
    | attribs.
    |
    | --
    |
    | -Jason
    | Member of the Autodesk Discussion Forum Moderator Program
    |
    |
    | | > You need to fix the Normal of the attributes, *and* the
    TextAlignmentPoint.
    |
    |
     
    R. Robert Bell, Jul 21, 2003
    #10
  11. Which is what I did, but the new attribs are in the same position
    as the old ones. Oh, but then all I need to do is "scoot" them over
    relative to the new insertion point?
     
    Jason Piercey, Jul 21, 2003
    #11
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.