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

0 Members and 1 Guest are viewing this topic.

notredave

  • Newt
  • Posts: 140
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: 140
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: 7526
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 11 x64 - AutoCAD /C3D 2023

Custom Build PC

notredave

  • Newt
  • Posts: 140
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: 7526
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 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ChrisCarlson

  • Guest
Re: Match block to desired size
« Reply #5 on: September 23, 2019, 05:14:29 PM »
Really the only option. However I would caution against even that method. I'd venture that certain aspects of that part doesn't scale up.

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Match block to desired size
« Reply #6 on: September 25, 2019, 11:22:22 PM »
The Diagrams have been made readable rather than true scale, not sure what convert pdf or raster to vector may do, but then could look at rubber mapping all the objects.This way circles stay just that still not exact but a lot closer. Had a look at the battery dwg same thing explode and may be able to do x y scaling on parts at a time.

Search for helmert transformation.
« Last Edit: September 25, 2019, 11:25:25 PM by BIGAL »
A man who never made a mistake never made anything