backward attribs - vla-insertBlock

Jason Piercey

Usenet Archive
Joined
Jun 30, 2003
Messages
868
Reaction score
0
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,
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
 
Well.... if I obtain the selected inserts normal property and apply it to the newly created insert, the attribs are still backwards.
 
unless I have to aplly the normal property to the insert and each of the attribs....
 
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
 
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 said:
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

Jason Piercey said:
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)
)
)
 
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. | |
 
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?
 

Latest threads

Back
Top