Author Topic: Move objects in a scale fashion  (Read 5376 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Move objects in a scale fashion
« on: February 21, 2008, 01:40:06 PM »
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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

M-dub

  • Guest
Re: Move objects in a scale fashion
« Reply #1 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!  :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Move objects in a scale fashion
« Reply #2 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))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move objects in a scale fashion
« Reply #3 on: February 21, 2008, 02:56:10 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!  :)

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

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))
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: [Select]
(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)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Move objects in a scale fashion
« Reply #4 on: February 22, 2008, 11:06:27 AM »
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: [Select]
(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)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move objects in a scale fashion
« Reply #5 on: February 22, 2008, 11:27:18 AM »
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: [Select]
(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)
)
It does work, but it is not generic enough.  The code should be able to move each object the way the scale command moves them.  Another problem is that some, if not all/most, of the leaders and text are not connected to each other.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Move objects in a scale fashion
« Reply #6 on: February 22, 2008, 12:37:17 PM »
I just don't see a way to move a leader & text without moving them together.
Maybe you will need to process each leader and acquire the nearest text to the end of the leader.
Very messy but the only way I see. :-(
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move objects in a scale fashion
« Reply #7 on: February 22, 2008, 12:44:47 PM »
I just don't see a way to move a leader & text without moving them together.
Maybe you will need to process each leader and acquire the nearest text to the end of the leader.
Very messy but the only way I see. :-(
Yea, and if that is the only way, then no need to try and automate it, as just moving each object(s) will be about the same amount of effort.  Thanks for trying.   :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

M-dub

  • Guest
Re: Move objects in a scale fashion
« Reply #8 on: February 22, 2008, 01:01:20 PM »
I guess I was asking about script, wondering how uniform these drawings are?  Just wondering if you could use coordinates to select your entities, move them etc.  That is likely the only way scripts would be useful.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move objects in a scale fashion
« Reply #9 on: February 22, 2008, 01:11:09 PM »
Yea.  I don't think a script will do it, but I was hoping you had some mad script skills that would just wow me.  :-)

I think it has to be a transformation matrix operation, but I'm not sure if it can be done.  I guess this will be one of those pet projects that will evolve over time.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

M-dub

  • Guest
Re: Move objects in a scale fashion
« Reply #10 on: February 22, 2008, 01:15:57 PM »
Yea.  I don't think a script will do it, but I was hoping you had some mad script skills that would just wow me.  :-)

I might have been able to get a Wow out of you, but I don't think I quite grasped the scope completely.  :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Move objects in a scale fashion
« Reply #11 on: February 22, 2008, 01:35:14 PM »
You can try this:
http://www.theswamp.org/index.php?topic=8916.msg114542#msg114542
but I think you will get the same results.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move objects in a scale fashion
« Reply #12 on: February 22, 2008, 02:27:02 PM »
You can try this:
http://www.theswamp.org/index.php?topic=8916.msg114542#msg114542
but I think you will get the same results.

Yup.  I think I'm out of luck.  I will see what I can come up with when I have time, but no time to play right now, w*rk calls.

Thanks for trying Guys.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Move objects in a scale fashion
« Reply #13 on: February 23, 2008, 12:08:22 PM »
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.  [...]

Have you tried CHSPACE ?
  • Use CHSPACE to move the annotations to MSPACE
  • Scale objects and change the scale of the viewport
  • Use CHSPACE to place the annotations in the layout again.
Vault Professional 2023     +     AEC Collection

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Move objects in a scale fashion
« Reply #14 on: February 23, 2008, 01:01:58 PM »
The problem Tim is having is that for objects to maintain there relative insertion point they must be moved based on that insertion point.
In the case of a leader & it's text the relevant point is the arrow head point and that group must be moved bases on that point if the leader & text are to stay aligned & the arrow head maintain it's relation to the new VP.


You see in this picture the only vector that produces the correct alignment point is the one to the leader arrow.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

FengK

  • Guest
Re: Move objects in a scale fashion
« Reply #15 on: February 23, 2008, 07:49:18 PM »
I'm with Crank on this one. When I'm in the similar situation (if I understood the question correctly), I'd first move all the paper space objects into model space, then make change to the viewport, and then move those objects back to paper space.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move objects in a scale fashion
« Reply #16 on: February 25, 2008, 11:04:44 AM »
I'm with Crank on this one. When I'm in the similar situation (if I understood the question correctly), I'd first move all the paper space objects into model space, then make change to the viewport, and then move those objects back to paper space.
But wouldn't that scale down (or up) the text to a different size?  It did on a simple test I did.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Move objects in a scale fashion
« Reply #17 on: February 25, 2008, 01:19:13 PM »
I think that was in AutoCAD2006.

The CHSPACE command has changed with the last releases. So it depends what version of Autocad you're using:
  • In 2006 it was written in lisp (express tool). Sometimes the prompt displayed a different scaling than the scale of the viewport. But I've never had any problems with the result.
  • In 2008 it moved to the core commands. There was a bug that you could only have one viewport on the layout. So I'm using a different lisp that deletes all the other viewports and replaces them after the change.
  • In 2009 this command finally seems OK :)
Vault Professional 2023     +     AEC Collection

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Move objects in a scale fashion
« Reply #18 on: February 25, 2008, 01:48:47 PM »
I'm in '06, but I don't see how it wouldn't be the same in any release since you are changing the scale of the viewport, so when it brings it back the scale factor for the objects are now different.  Leaders maybe not so much, but text is the problem.  Will test some more later.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.