notredave Posted December 5, 2017 Share Posted December 5, 2017 Morning all, I am trying to match block on left (2500-RBC) to match block on right (TEST)with x and y axis. I have tried matchblock.lsp with no luck. I have tried changing the properties with no luck. Can someone please help me make the x and y axis match without exploding the block (2500-RBC)? Thank you in advance, David TEST.dwg Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 5, 2017 Share Posted December 5, 2017 Hi, Something like this? (defun c:matchxy (/ en1 en2) (and (setq en1 (car (entsel "\nSelect 1st block to move to next block's X & Y :" ) ) ) (or (= (cdr (assoc 0 (setq en1 (entget en1)))) "INSERT") (alert "Invlaid object !") ) (setq en2 (car (entsel "\nSelect 2nd block :"))) (or (= (cdr (assoc 0 (setq en2 (entget en2)))) "INSERT") (alert "Invlaid object !") ) (entmod (subst (assoc 10 en2) (assoc 10 en1) en1)) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted December 5, 2017 Share Posted December 5, 2017 Are you referring to the size, or matching insertion points like Tharwat did? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 5, 2017 Share Posted December 5, 2017 But if you are after changing the scale of XYZ then just replace the following line of codes with the one in the above posted codes that I posted earlier. (entmod (append en1 (list (assoc 41 en2) (assoc 42 en2) (assoc 43 en2)))) Quote Link to comment Share on other sites More sharing options...
notredave Posted December 5, 2017 Author Share Posted December 5, 2017 I am referring to the size to match Quote Link to comment Share on other sites More sharing options...
ronjonp Posted December 5, 2017 Share Posted December 5, 2017 With that test drawing, you'd need to grab the size of the bounding box then apply. The two blocks are different sizes at the same scale. Quote Link to comment Share on other sites More sharing options...
notredave Posted December 5, 2017 Author Share Posted December 5, 2017 Thawart, I tried this appended code you made (defun c:matchxy (/ en1 en2) (and (setq en1 (car (entsel "\nSelect 1st block to move to next block's X & Y :" ) ) ) (or (= (cdr (assoc 0 (setq en1 (entget en1)))) "INSERT") (alert "Invlaid object !") ) (setq en2 (car (entsel "\nSelect 2nd block :"))) (or (= (cdr (assoc 0 (setq en2 (entget en2)))) "INSERT") (alert "Invlaid object !") ) (entmod (append en1 (list (assoc 41 en2) (assoc 42 en2) (assoc 43 en2)))) ) (princ) ) But, when I click on first block (larger one) to match smaller one, it get's larger Quote Link to comment Share on other sites More sharing options...
notredave Posted December 5, 2017 Author Share Posted December 5, 2017 ronjonp, could you please explain to me on how to do that (grabbing the side of the bounding box and apply)? That is new to me. Thank you! Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted December 5, 2017 Share Posted December 5, 2017 Do you need a code, or just that DWG... If the second, I'll attach it to you... It's fairly simple to reset RS-2500 block to scale 1,1,1 and then to recalculate what is each X,Y scale factor according to dimensions of your TEST block... TEST.dwg Quote Link to comment Share on other sites More sharing options...
notredave Posted December 5, 2017 Author Share Posted December 5, 2017 marko_ribar, thank you! If you have a code that does that, I will gladly take and use it on others I have to scale. Thank you and thanks to all who replied. I really appreciate it! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 5, 2017 Share Posted December 5, 2017 But, when I click on first block (larger one) to match smaller one, it get's larger Simply reverse the DXF list to do the contrary task like this: Replace this: (entmod (append en1 (list (assoc 41 en2) (assoc 42 en2) (assoc 43 en2)))) With this: (entmod (append en2 (list (assoc 41 en1) (assoc 42 en1) (assoc 43 en1)))) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted December 5, 2017 Share Posted December 5, 2017 Here, try this code : (defun c:rescaleblkbycorners ( / blk p1 p2 ll ur minpt maxpt ) (vl-load-com) (prompt "\nSelect block you want to rescale on unlocked layer...") (setq blk (ssname (ssget "_+.:E:S:L" '((0 . "INSERT"))) 0)) (if blk (progn (setq p1 (getpoint "\nPick or specify corner point : ")) (setq p2 (getcorner p1 "\nPick or specify other corner point : ")) (setq ll (list (apply 'min (mapcar 'car (list p1 p2))) (apply 'min (mapcar 'cadr (list p1 p2)))) ur (list (apply 'max (mapcar 'car (list p1 p2))) (apply 'max (mapcar 'cadr (list p1 p2))))) (entupd (cdr (assoc -1 (entmod (subst (cons 41 1.0) (assoc 41 (entget blk)) (entget blk)))))) (entupd (cdr (assoc -1 (entmod (subst (cons 42 1.0) (assoc 42 (entget blk)) (entget blk)))))) (entupd (cdr (assoc -1 (entmod (subst (cons 43 1.0) (assoc 43 (entget blk)) (entget blk)))))) (vla-getboundingbox (vlax-ename->vla-object blk) 'minpt 'maxpt) (mapcar 'set '(minpt maxpt) (mapcar 'safearray-value (list minpt maxpt))) (entupd (cdr (assoc -1 (entmod (subst (cons 41 (/ (- (car ur) (car ll)) (- (car maxpt) (car minpt)))) (assoc 41 (entget blk)) (entget blk)))))) (entupd (cdr (assoc -1 (entmod (subst (cons 42 (/ (- (cadr ur) (cadr ll)) (- (cadr maxpt) (cadr minpt)))) (assoc 42 (entget blk)) (entget blk)))))) (vla-getboundingbox (vlax-ename->vla-object blk) 'minpt 'maxpt) (mapcar 'set '(minpt maxpt) (mapcar 'safearray-value (list minpt maxpt))) (vla-move (vlax-ename->vla-object blk) (vlax-3d-point minpt) (vlax-3d-point ll)) ) ) (princ) ) I thought ab this and I wrote the code that will ask you to pick block and 2 corner points to match desired size... So actually you don't need reference block, just rectangle or even nothing just try to pick 2 points and it'll scale to match that bounding box... Regards, M.R. Quote Link to comment Share on other sites More sharing options...
notredave Posted December 6, 2017 Author Share Posted December 6, 2017 All, Thank you very much for all of your help. It's working for me now. You guys and CADTutor is the best place to come for help when needed. It hasn't disappointed me yet! Thanks again gents, David Quote Link to comment Share on other sites More sharing options...
SLW210 Posted December 6, 2017 Share Posted December 6, 2017 Please read the Code Posting Guidelines and edit your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.