Jump to content
Developer Wiki and Function Reference Links Read more... ×

Recommended Posts

Is there a way to make a script that when I have object in my design layer . they can all move inside the paper space center . 

thank you in advance for anyone that knows if thats possible.

thanks.

Share this post


Link to post

Yes you can have a script that will move objects.

 

What are you trying to do? Do you want to move objects so they fit on the page? Do you care if the relative position of the objects changes? 


Or, do you want to change the scale so the objects fit on the page while still retaining the same relative positions?

 

Both are possible.

Share this post


Link to post

No Change in Scale. Just If the object Can move inside the page.

I usually work with solid object like rectangle Frames . 

It would be nice if they can be moved to the center of the page .

If thats not possible well does not matter what position they go inside the page . 

Thanks

Share this post


Link to post

Here is a real quick version. It has only been run once, so use at your own risk. Test on a backup before trusting to your real data.

 

Draw a rectangle the size of your page and name it MyPage at the bottom of the OIP.

 

The script will move all objects that are outside of the MyPage object so that the bottom left corner of the bounding box is at the page center.

 

Lots of enhancements possible, but at least you have an outline. 

 

As again if you have more questions.

 

Procedure Test;

Procedure DoIt(H1:Handle);
Var	X1,Y1,X2,Y2:Real;
	Begin
		GetBBox(H1,X1,Y1,X2,Y2);
		HMove(H1,-X1,-Y2);
	End;
	
Begin
	ForEachObject(DoIt,((LOC<>'MyPage')));
End;

Run(Test);

 

Share this post


Link to post

Hello at first I thought it was going at the origin of the x,y  so I moved the origin to the center of the page . but the objects move to the side of the page nowhere inside . 

Share this post


Link to post

I notice if I have multiple objects all of them automatically move there . can it be just for selected object to do the move? thanks.

Share this post


Link to post

Sorry I did say all objects when asking for a script, I was not thinking . I would like it to be for selected objects . thanks 

Share this post


Link to post

The script gets the Bounding Box of the objects and moves the bottom left point of the bounding box to 0,0. So if 0,0 if off you page then the objects will move to off your page.

 

To work on selected objects only, edit the ForEachObject line:

 

ForEachObject(DoIt,(((LOC<>'MyPage') & (VSEL=TRUE))));

 

Share this post


Link to post

This script works perfect . another thing since I usually work with squares can the move location be from the center of my object . if not its alright. This script is already working good 😄

Share this post


Link to post

Untested but change the Hmove  line to:

 

HMove(H1,-(X1+X2)/2,-(Y1+Y2)/2);

 

Share this post


Link to post

Nice!!!!! It work thank you. . I would like to learn on how to script, but I don't even know how to start a script . 

 

for example I simple rectangle I don't even know how to start a rectangle .  are there any tips on how start any procedure ? thank you

 

Share this post


Link to post

where I work. they have this script of a frame that already has multiple functions it can be change size and it can be made out of alluminum or plywood. but I want to start learning script so I can tweak it little bit like make drill hole anywhere on the frame . 

Share this post


Link to post

I know this will take a long time to make it work so I wanna start basic with a rectangle . 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×