cdavis Posted November 29, 2007 Share Posted November 29, 2007 I want to scale 40 objects to be larger, but they scale from the average center of the entire group and this moves them out from their average center. I want each object to scale from its own center and stay in the same position. Is this possible? Quote Link to comment
Vectorworks, Inc Employee Robert Anderson Posted November 29, 2007 Vectorworks, Inc Employee Share Posted November 29, 2007 This can be done only with a VectorScript. Quote Link to comment
Pat Stanford Posted November 29, 2007 Share Posted November 29, 2007 And here is a script that will do this. Copy the the lines from Procedure to Run and paste them into a new VectorScript Editor window. {==============================} Procedure ScaleEachObject; {Scales each selected object in the active layer around the obejct center} {? 2007, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed unde the GNU Lesser General Public License} Var H1,H2:Handle; N1,N2:Integer; A1:Dynarray[ ] of handle; R1:Real; Begin N1:=Count(Sel); If N1>0 then Begin Allocate A1[1..N1]; N2:=1; While N2<=N1 do Begin A1[N2]:=FSActLayer; SetDSelect(FSActLayer); N2:=N2+1; End; R1:=RealDialog('Enter the amount to scale each object by','2.0'); N2:=1; While N2<=N1 do Begin SetSelect(A1[N2]); Scale(R1,R1); DSelectAll; N2:=N2+1; End; End else AlrtDialog('At least one object must be selected'); End; Run(ScaleEachObject); {===================================} Pat Quote Link to comment
Chris D Posted November 29, 2007 Share Posted November 29, 2007 Procedure ScaleEachObject; {Scales each selected object in the active layer around the obejct center} Pat, this looks useful. How about adding it to the new sharing forums so that it doesn't get lost. {? 2007, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed unde the GNU Lesser General Public License} This might be a useful compromise rather than relinquishing copyright for your hard work when sharing resources. Quote Link to comment
Jershaun Posted November 30, 2007 Share Posted November 30, 2007 Thanks Mr. Stanford This is really generous of you. This is a helpfull tool. Thanks for sharing. Quote Link to comment
jwlyon1 Posted December 6, 2007 Share Posted December 6, 2007 Holy Cow! This is great. Thanks for this tool. And I even learned a ton just through the creation of this tool on my computer! Thanks again. Quote Link to comment
Pat Stanford Posted November 17, 2010 Share Posted November 17, 2010 Here is a revised version that fixes a bug I either missed or that was introduced in a later version of VW. Tested on VW2011. The bug was when only groups were selected the script would incorrectly say not objects were selected and set stuck at the error message. Procedure ScaleEachObject; {Scales each selected object in the active layer around the obejct center} {? 2007, 2010, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed unde the GNU Lesser General Public License} Var H1,H2:Handle; N1,N2:Integer; A1:Dynarray[ ] of handle; R1:Real; Begin N1:=Count(Sel); If N1>0 then Begin Allocate A1[1..N1]; N2:=1; While N2<=N1 do Begin A1[N2]:=FSActLayer; SetDSelect(FSActLayer); N2:=N2+1; End; R1:=RealDialog('Enter the amount to scale each object by','2.0'); N2:=1; While N2<=N1 do Begin SetSelect(A1[N2]); Scale(R1,R1); DSelectAll; N2:=N2+1; End; End else Begin N1:=0; AlrtDialog('At least one object must be selected'); End; End; Run(ScaleEachObject); Quote Link to comment
Uli Posted March 27, 2014 Share Posted March 27, 2014 I just found this script, thank you very much Quote Link to comment
nicolas d Posted December 15, 2015 Share Posted December 15, 2015 I just found this script too, thanks a lot!!! Quote Link to comment
Asemblance Posted August 15, 2016 Share Posted August 15, 2016 Just upgraded from 2009 to 2016, and can't seem to get this script to work anymore. Does anyone know if there is now a way to do this in the more recent vwx releases? P.S. Thanks to Pat, as I was using this in the past and saved me a lot of time! Quote Link to comment
michaelk Posted August 16, 2016 Share Posted August 16, 2016 Works for me on 2016. Are you using the newer version of the script? Quote Link to comment
HEengineering Posted August 16, 2016 Share Posted August 16, 2016 Hmm I can't get either to work. New or old? Quote Link to comment
AlanW Posted August 16, 2016 Share Posted August 16, 2016 Works lovely, Just go resource browser and create new script, past in and voula. Select a few objects and double click on the script and you get a scale option up. Quote Link to comment
HEengineering Posted August 16, 2016 Share Posted August 16, 2016 (edited) User error. Looks to be working now. Must have missed a line somewhere at the end. You guys are great. Pat your the man! Edited August 16, 2016 by HEengineering Quote Link to comment
Asemblance Posted September 5, 2016 Share Posted September 5, 2016 Thanks for your replies - I'm still having problems with the script. I can now seem to get it to scale, but only after a huge number of error boxes of 'no objects selected'. I've recorded a short video showing my process, perhaps I'm going wrong somewhere? Screen Recording Link - If anyone has any advice I'd be greatful as its a very useful tool! Thanks Quote Link to comment
twk Posted September 5, 2016 Share Posted September 5, 2016 (edited) Here's my attempt using Python. (attached txt file version of script) My vectorscript is very rusty. ** YOU NEED TO MAKE SURE YOU SET YOUR SCRIPTING LANGUAGE TO PYTHON (IN THE SCRIPT EDITOR)** # DISCLAIMER # - Python Novice # - Script presented as is # - save your work before using # - use at your own risk # - no responsibilty taken for damage to your property from the use of this script # - copyright twk 2016 # - forum link = https://forum.vectorworks.net/index.php?/topic/19675-how-can-i-scale-multiple-objects-from-each-objects-center/ # - Tested on Windows 10 x64, Vectorworks 2016 SP4 def List_SelectedObjs_in_Layer(): # small function to store all selected objects on the current layer into a usable list (python list) h_FirstInContainer = vs.FIn3D(vs.ActLayer()) listObjs_inContainer = [] while (h_FirstInContainer != None): if vs.Selected(h_FirstInContainer): listObjs_inContainer.append(h_FirstInContainer) h_FirstInContainer = vs.NextObj(h_FirstInContainer) return listObjs_inContainer list_selObjs = List_SelectedObjs_in_Layer() # function called, selected objects stored countIt = len(list_selObjs) # number of selected objs store in countIt variable if countIt > 0: # checking to make sure at least 1 or more objects are selected scaleAmount = vs.RealDialog("Enter Scale Amount", "1.5") if not vs.DidCancel(): # checking to make sure predefined Dialog's OK button was pressed for eachObj in list_selObjs: center = vs.HCenter(eachObj) # getting center of obj to be used in next function vs.HScale2D(eachObj,center[0],center[1],scaleAmount, scaleAmount, True) vs.ReDrawAll() # redraw-ing the screen as is needed after running HScale2D vs.AlrtDialog("{} Objs scaled".format(countIt)) #indicates the number of objects scaled else: vs.AlrtDialog("At least 1 object must be selected") # checking to make sure at least 1 or more objects are selected vs_scaleEachObj.txt Edited August 11, 2019 by twk changed language encoding 1 Quote Link to comment
Asemblance Posted September 6, 2016 Share Posted September 6, 2016 twk - Thanks, just used the python version of the script you posted, appears to work for me without issue! Quote Link to comment
T_D_N Posted November 24, 2017 Share Posted November 24, 2017 On 05/09/2016 at 3:29 PM, Asemblance said: Thanks for your replies - I'm still having problems with the script. I can now seem to get it to scale, but only after a huge number of error boxes of 'no objects selected'. I've recorded a short video showing my process, perhaps I'm going wrong somewhere? Screen Recording Link - If anyone has any advice I'd be greatful as its a very useful tool! Thanks This can be fixed by replacing line: N1:=Count(Sel); With an option to select only the visible selections N1:=Count((VSEL=TRUE)); Quote Link to comment
line-weight Posted August 9, 2019 Share Posted August 9, 2019 On 9/5/2016 at 4:57 PM, twk said: Here's my attempt using Python. (attached txt file version of script) My vectorscript is very rusty. ** YOU NEED TO MAKE SURE YOU SET YOUR SCRIPTING LANGUAGE TO PYTHON (IN THE SCRIPT EDITOR)** # DISCLAIMER # - Python Novice # - Script presented as is # - save your work before using # - use at your own risk # - no responsibilty taken for damage to your property from the use of this script # - copyright twk 2016 # - forum link = https://forum.vectorworks.net/index.php?/topic/19675-how-can-i-scale-multiple-objects-from-each-objects-center/ # - Tested on Windows 10 x64, Vectorworks 2016 SP4 def List_SelectedObjs_in_Layer(): # small function to store all selected objects on the current layer into a usable list (python list) h_FirstInContainer = vs.FIn3D(vs.ActLayer()) listObjs_inContainer = [] while (h_FirstInContainer != None): if vs.Selected(h_FirstInContainer): listObjs_inContainer.append(h_FirstInContainer) h_FirstInContainer = vs.NextObj(h_FirstInContainer) return listObjs_inContainer list_selObjs = List_SelectedObjs_in_Layer() # function called, selected objects stored countIt = len(list_selObjs) # number of selected objs store in countIt variable if countIt > 0: # checking to make sure at least 1 or more objects are selected scaleAmount = vs.RealDialog("Enter Scale Amount", "1.5") if not vs.DidCancel(): # checking to make sure predefined Dialog's OK button was pressed for eachObj in list_selObjs: center = vs.HCenter(eachObj) # getting center of obj to be used in next function vs.HScale2D(eachObj,center[0],center[1],scaleAmount, scaleAmount, True) vs.ReDrawAll() # redraw-ing the screen as is needed after running HScale2D vs.AlrtDialog("{} Objs scaled".format(countIt)) #indicates the number of objects scaled else: vs.AlrtDialog("At least 1 object must be selected") # checking to make sure at least 1 or more objects are selected vs_scaleEachObj.txt I've just been trying to use this to scale multiple 3d objects. Realised that it uses the 2d scale command, which is why it didn't work. I tried replacing the vs.Hscale2D in line 29 with vs.HSacle3D ... adding a 3rd center[] and a 3rd scaleAmount in the hope that might work - but no luck. Completely out of my depth trying to work out why! Quote Link to comment
twk Posted August 10, 2019 Share Posted August 10, 2019 Swapped out the HScale2D for HScale3D, and seems to scaling fine here. Working on Extrudes though. What particular 3D objects where you trying to scale? # DISCLAIMER # - Python Novice # - Script presented as is # - save your work before using # - use at your own risk # - no responsibilty taken for damage to your property from the use of this script # - copyright twk 2016 # - forum link = https://forum.vectorworks.net/index.php?/topic/19675-how-can-i-scale-multiple-objects-from-each-objects-center/ # - Tested on Windows 10 x64, Vectorworks 2016 SP4 def List_SelectedObjs_in_Layer(): # small function to store all selected objects on the current layer into a usable list (python list) h_FirstInContainer = vs.FIn3D(vs.ActLayer()) listObjs_inContainer = [] while (h_FirstInContainer != None): if vs.Selected(h_FirstInContainer): listObjs_inContainer.append(h_FirstInContainer) h_FirstInContainer = vs.NextObj(h_FirstInContainer) return listObjs_inContainer list_selObjs = List_SelectedObjs_in_Layer() # function called, selected objects stored countIt = len(list_selObjs) # number of selected objs store in countIt variable if countIt > 0: # checking to make sure at least 1 or more objects are selected scaleAmount = vs.RealDialog("Enter Scale Amount", "1.5") if not vs.DidCancel(): # checking to make sure predefined Dialog's OK button was pressed for eachObj in list_selObjs: center = vs.HCenter(eachObj) # getting center of obj to be used in next function # vs.HScale2D(eachObj,center[0],center[1],scaleAmount, scaleAmount, True) vs.HScale3D(eachObj, center[0], center[1], 0, scaleAmount, scaleAmount, scaleAmount) vs.ReDrawAll() # redraw-ing the screen as is needed after running HScale2D vs.AlrtDialog("{} Objs scaled".format(countIt)) #indicates the number of objects scaled else: vs.AlrtDialog("At least 1 object must be selected") # checking to make sure at least 1 or more objects are selected 1 Quote Link to comment
Boh Posted August 11, 2019 Share Posted August 11, 2019 Great scripts. Very handy, thankyou! Quote Link to comment
line-weight Posted August 12, 2019 Share Posted August 12, 2019 On 8/10/2019 at 6:33 AM, twk said: Swapped out the HScale2D for HScale3D, and seems to scaling fine here. Working on Extrudes though. What particular 3D objects where you trying to scale? # DISCLAIMER # - Python Novice # - Script presented as is # - save your work before using # - use at your own risk # - no responsibilty taken for damage to your property from the use of this script # - copyright twk 2016 # - forum link = https://forum.vectorworks.net/index.php?/topic/19675-how-can-i-scale-multiple-objects-from-each-objects-center/ # - Tested on Windows 10 x64, Vectorworks 2016 SP4 def List_SelectedObjs_in_Layer(): # small function to store all selected objects on the current layer into a usable list (python list) h_FirstInContainer = vs.FIn3D(vs.ActLayer()) listObjs_inContainer = [] while (h_FirstInContainer != None): if vs.Selected(h_FirstInContainer): listObjs_inContainer.append(h_FirstInContainer) h_FirstInContainer = vs.NextObj(h_FirstInContainer) return listObjs_inContainer list_selObjs = List_SelectedObjs_in_Layer() # function called, selected objects stored countIt = len(list_selObjs) # number of selected objs store in countIt variable if countIt > 0: # checking to make sure at least 1 or more objects are selected scaleAmount = vs.RealDialog("Enter Scale Amount", "1.5") if not vs.DidCancel(): # checking to make sure predefined Dialog's OK button was pressed for eachObj in list_selObjs: center = vs.HCenter(eachObj) # getting center of obj to be used in next function # vs.HScale2D(eachObj,center[0],center[1],scaleAmount, scaleAmount, True) vs.HScale3D(eachObj, center[0], center[1], 0, scaleAmount, scaleAmount, scaleAmount) vs.ReDrawAll() # redraw-ing the screen as is needed after running HScale2D vs.AlrtDialog("{} Objs scaled".format(countIt)) #indicates the number of objects scaled else: vs.AlrtDialog("At least 1 object must be selected") # checking to make sure at least 1 or more objects are selected Thanks for that. I tried it on a bunch of extrudes. It did scale them all, but it didn't seem to scale relative to each object's centre. Here is the before & after (lines on the ground are for reference and weren't scaled): Quote Link to comment
line-weight Posted August 12, 2019 Share Posted August 12, 2019 Another observation - it doesn't seem to work on objects that are within a group. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.