cdavis 0 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 Share this post Link to post
Robert Anderson 129 Posted November 29, 2007 This can be done only with a VectorScript. Quote Share this post Link to post
Pat Stanford 1,527 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 Share this post Link to post
Chris D 3 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 Share this post Link to post
Jershaun 9 Posted November 30, 2007 Thanks Mr. Stanford This is really generous of you. This is a helpfull tool. Thanks for sharing. Quote Share this post Link to post
jwlyon1 0 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 Share this post Link to post
Pat Stanford 1,527 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 Share this post Link to post
Uli 2 Posted March 27, 2014 I just found this script, thank you very much Quote Share this post Link to post
nicolas d 1 Posted December 15, 2015 I just found this script too, thanks a lot!!! Quote Share this post Link to post
Asemblance 33 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 Share this post Link to post
michaelk 508 Posted August 16, 2016 Works for me on 2016. Are you using the newer version of the script? Quote Share this post Link to post
HEengineering 16 Posted August 16, 2016 Hmm I can't get either to work. New or old? Quote Share this post Link to post
AlanW 527 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 Share this post Link to post
HEengineering 16 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 Share this post Link to post
Asemblance 33 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 Share this post Link to post
twk 236 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 Share this post Link to post
Asemblance 33 Posted September 6, 2016 twk - Thanks, just used the python version of the script you posted, appears to work for me without issue! Quote Share this post Link to post
T_D_N 0 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 Share this post Link to post
line-weight 771 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 Share this post Link to post
twk 236 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 Share this post Link to post
Boh 461 Posted August 11, 2019 Great scripts. Very handy, thankyou! Quote Share this post Link to post
line-weight 771 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 Share this post Link to post
line-weight 771 Posted August 12, 2019 Another observation - it doesn't seem to work on objects that are within a group. Quote Share this post Link to post