Last time I talked about the principle of deep cloning and cloning objects from tiles to model space. For details, see:
============
Deep clone objects between arbitrary spaces (1) - Block TO MS:
http://www.theswamp.org/index.php?topic=58859.0Deep clone objects between arbitrary spaces (2) - MS TO Block:
http://www.theswamp.org/index.php?topic=58860.0Deep clone objects between arbitrary spaces (3) - BLOCK TO PS:
http://www.theswamp.org/index.php?topic=58862.0============
Today, we will continue to talk about the opposite operation, cloning objects from block to block.
The following demonstrates cloning the original text position of BLOCK1 to another BLOCK2.
![](http://www.theswamp.org/index.php?action=dlattach;topic=58863.0;attach=41790;image)
(defun c:txt
-block
->block
() (setq txt1
(xdrx
-nentselex
"\nPick source Text Object IN Block<Exit>:" '
((0 .
"text")))) (setq blkref2
(car (xdrx
-entsel "\nPick Dest Block<Exit>:" '
((0 .
"insert")))))
(setq mat
-block1
->ms
(xdrx
-matrix
-block2wcs blkref1
);wcs->block transform Matrix mat-block1->ms (xdrx-matrix-inverse mat-block1->ms));block->mspace transform Matrix
(setq mat
-ms
->block2
(xdrx
-matrix
-block2wcs blkref2
));wcs->block transform Matrix
(setq block2space
(xdrx
-getpropertyvalue blkref2
"blocktablerecord" t
))
;;ms->ps,mat-block->ms,Multiply the matrix to the left
(setq mat
-block1
->block2
(xdrx
-matrix
-product mat
-ms
->block2 mat
-block1
->ms
)) )
;|
1.Deep cloning, clone objects in any space (block table records, symbol table records, dictionary)
2.ownerid is the model space block table record, and the transformation matrix is mat-block2wcs
3.Complete the in-situ cloning of the text from the block's block table record to the another Block.
|;
(setq txt
-block2
(xdrx
-object
-deepclone block2space txt1 mat
-block1
->block2
));;Clone into Block2 (xdrx
-setpropertyvalue
(car txt
-block2
) "textstring" (xdrx-string-format "I'm In %s" block2name)
"color" 2
)
(xdrx-object-regen blkref2)
)
)
)