Author Topic: Match block to desired size  (Read 223 times)

0 Members and 1 Guest are viewing this topic.

notredave

  • Newt
  • Posts: 105
Match block to desired size
« on: September 09, 2019, 12:54:46 PM »
Good morning all to my friends,

If you see attached drawing that I downloaded for a vendor site, it is not to scale. Does anybody have a match scale lisp routine that are willing to share. When I scale this block up to correct "x" dimension by percentage, my "x" dimension is correct but my "y" dimension is not. I am looking to make a rectang with correct dimension and hope to match block to my rectang size keeping components inside block uniformly correct. I am trying to have width at 12.95" X 8.72". I would greatly appreciate this as I download plenty of vendor drawings that need re-scaling with correct dimensions and hoping the routine works on all that I download and need uniform scaling.

Thank you,
David

notredave

  • Newt
  • Posts: 105
Re: Match block to desired size
« Reply #1 on: September 18, 2019, 12:15:29 PM »
Gents,

Good morning, what I'm I doing wrong??? I am using Jim Clayton, Matchblockscale.lsp located here: https://www.cadtutor.net/forum/topic/68676-match-block-to-desired-size/. But my attached drawing isn't matching. I need power block on left to scale to rectang block on right, keeping circles, etc to proportion. If someone can take a look at this and tell me what's going on with this, I would appreciate it.

Thank you,
David

ronjonp

  • Needs a day job
  • Posts: 7025
Re: Match block to desired size
« Reply #2 on: September 18, 2019, 04:01:22 PM »
This code relies on you to have the correct ratio for scaling and assumes the target block is at a scale of 1. Will bomb if your target block has uniform scale set.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ a b c d ll s ur)
  2.   ;; RJP 2019-09-18
  3.   (if (and (setq a (getpoint "\nSpecify first corner point: "))
  4.            (setq b (getcorner a "\nSpecify other corner point: "))
  5.            (setq c (mapcar 'abs (mapcar '- a b)))
  6.            (setq s (ssget ":L" '((0 . "insert"))))
  7.       )
  8.     (foreach o (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
  9.       (vla-getboundingbox o 'll 'ur)
  10.       (setq d (mapcar 'abs (mapcar '- (vlax-safearray->list ll) (vlax-safearray->list ur))))
  11.       (vla-put-xscalefactor o (/ (car c) (car d)))
  12.       (vla-put-yscalefactor o (/ (cadr c) (cadr d)))
  13.     )
  14.   )
  15.   (princ)
  16. )

The reason that other code does not work is because both of your blocks have a scale of 1.
« Last Edit: September 18, 2019, 04:06:48 PM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

notredave

  • Newt
  • Posts: 105
Re: Match block to desired size
« Reply #3 on: September 19, 2019, 10:00:38 AM »
ronjonp,

Thank you for answering. Attached drawing is an example with write up that might clear things up.I do this quite a bit with vendor pdf.s when they don't have cad drawings for download.

ronjonp

  • Needs a day job
  • Posts: 7025
Re: Match block to desired size
« Reply #4 on: September 19, 2019, 12:35:27 PM »
I would suggest setting lock aspect to 'no' then scaling the image to the correct ratio and trace it.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC