Code Red > AutoLISP (Vanilla / Visual)

Move objects in a scale fashion

(1/4) > >>

T.Willey:
I don't know how possible this is to move objects in a scale fashion.  I tried some simple ways, but they didn't work.  Then I thought about trying to do it with a transformation matrix, but I'm not that good with them, and I couldn't think of a way.

The reason is because I have drawings that were setup one way (not the way we want them to be), and I have to change them to the correct setup.  All the notes are in paper space, and when I redo the setup the scale of the viewports are going to change, and I want an automatic way to move the notes to the correct locations.

Thanks for any tips.

M-dub:
Would this have to be lisp?  Could it not be done with a script?  I suppose it would mean that all drawings would have to be located at the same origins and be the same sizes, etc....

Just wonderin'... I can do script!  :)

CAB:
Maybe this?

Get the center of the vp in paper space = [CVP]
Calc distance ratio to move, (/ New_scale old_scale) = [DR]
Calc new text point, (polar CVP (angle CVP old_pt) (* (distance CVP old_pt) DR))

T.Willey:

--- Quote from: M-dub on February 21, 2008, 02:04:22 PM ---Would this have to be lisp?  Could it not be done with a script?  I suppose it would mean that all drawings would have to be located at the same origins and be the same sizes, etc....

Just wonderin'... I can do script!  :)

--- End quote ---

How would you do it in script?  If it can be done in script, then it can be done in lisp.


--- Quote from: CAB on February 21, 2008, 02:37:10 PM ---Maybe this?

Get the center of the vp in paper space = [CVP]
Calc distance ratio to move, (/ New_scale old_scale) = [DR]
Calc new text point, (polar CVP (angle CVP old_pt) (* (distance CVP old_pt) DR))

--- End quote ---
I tried something similar.  I got a base point, then I got the center of the bounding box of each object.  I then Move the objects the ratio of the difference in scales.  They were close, but not exact.  Here was my code.


--- Code: ---(defun c:MoveScale (/ ActDoc ScFac ll ur MidPt)
   
    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vla-EndUndoMark ActDoc)
    (vla-StartUndoMark ActDoc)
    (if
        (and
            (setq BsPt (getpoint "\n Select base point for move/scale operation: "))
            (setq ScFac (getreal "\n Enter scale factor: "))
            (setq BsPt (trans BsPt 1 0))
            (ssget)
        )
        (vlax-for obj (vla-get-ActiveSelectionSet ActDoc)
            (vla-GetBoundingBox obj 'll 'ur)
            (setq MidPt
                (mapcar
                    '(lambda (a b)
                        (/
                            (+ a b)
                            2.
                        )
                    )
                    (safearray-value ll)
                    (safearray-value ur)
                )
            )
           
            (vlax-invoke obj 'Move MidPt (polar MidPt (angle MidPt BsPt) (* ScFac (distance MidPt BsPt))))
        )
    )
    (vla-EndUndoMark ActDoc)
    (princ)
)

--- End code ---

CAB:
This is my take on the situation.

The problem is the bounding box.
Use this code with a leader & text. Select the VP center & then the point of the leader.
The move is correct. You would need to move objects by type of object and when there
is an association like a leader you would need to move them as a pair.


--- Code: ---(defun c:myMove (/ bspt scfac ss objpt)
  (setq BsPt (getpoint "\n Select base point for move/scale operation: "))
  (setq ScFac (getdist "\n Enter scale factor: "))
  (setq ss (ssget))
  (setq ObjPt (getpoint "\n Select base point of object: "))

  (command "move"
           ss
           ""
           ObjPt
           (polar ObjPt (angle ObjPt BSPt) (* (distance ObjPt BSPt) ScFac))
  )
  (princ)
)
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version