Jump to content

*HELP* Trying to match block size in x and y axis


notredave

Recommended Posts

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

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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))))

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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))))

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...