VectorBub Posted January 15, 2010 Share Posted January 15, 2010 (edited) I've just started poking around with scripts, and I'm trying to do something I thought would be pretty simple: create a script to increase the radius of all selected circles. The script correctly loops through all arc/circle objects (GetType(h)=6) and I can have it display the radius using HWidth(h)/2 and add the user's input change value, add them and display the correct new value to set --- I just can't find any way to set the radius. HWidth does provide a correct value, but it's read-only. It looked like there might be a specific Set function for radius, but I don't see one. I tried GetObjectAttributeReal -- but it asks for a property index. I don't know what to enter, and I can't find any listing anywhere. I don't really think the radius is an attribute anyway. It's part of the object info palette, not the attributes palette. (I even tried looping through index 0 to 10000, setting the script to stop when it found a match for the current radius. No luck.) I've been searching for two days, and my emoticon accurately describes my current emotional state. Anyone? (And where can I find the object property index listing?) Edited January 15, 2010 by VectorBub 1 Quote Link to comment
brudgers Posted January 15, 2010 Share Posted January 15, 2010 With circles, "scale (x, y)" would probably work well. Since I'm dense, I would: 1. create an array of handles 2. ForEachObject criteria (sel=True) --> populate array with the handle of the selected objects 3. deselectall 4 While LOOP select array element, scale it, deselectall. Alternatively: 1. get center of existing circle 2. draw new circle of desired size at the locaton 3. delete old circle. The downside of the alternative is that it will not preserve entity names and stacking order. Quote Link to comment
Pat Stanford Posted January 15, 2010 Share Posted January 15, 2010 Try this as a starting point. http://techboard.vectorworks.net/ubbthreads/ubbthreads.php?ubb=showflat&Number=94550&Searchpage=1&Main=20191&Words=scale&Search=true#Post94550 Quote Link to comment
Kool Aid Posted January 15, 2010 Share Posted January 15, 2010 I've been searching for two days, and my emoticon accurately describes my current emotional state. Anyone? (And where can I find the object property index listing?) The (documented) Object Variables are listed in the Additional Resources of VS Reference. There's no such thing as an ObjectAttributeReal. Get/SetBBox should work in your particular case. Quote Link to comment
Miguel Barrera Posted January 15, 2010 Share Posted January 15, 2010 As an alternate solution and if they are all circles or 360 degree arcs, yo can use SetBBox: {Get center of original circle} GetBBox(circleHdl,p1X,p1Y,p2X,p2Y); centerX:= (p1X+p2X)/2; centerY:= (p1Y+p2Y)/2; {Change the circle radius} SetBBox(circleHdl,centerX-rad2,centerY+rad2,centerX+rad2,centerY-rad2); Quote Link to comment
Kool Aid Posted January 15, 2010 Share Posted January 15, 2010 Ahh, a good point, Miguel! Off the top of my head, I can't devise a routine to scale an arc segment. Surely it is doable, but not obvious. (I might first make the arc 360?, then change the BBox, finally reset the original angles. Off the top of my head?) Quote Link to comment
Pat Stanford Posted January 15, 2010 Share Posted January 15, 2010 Did either of you try SetBBox on circles? I did before I posted last night and it does not work. It does work on ovals, but not on circles. Do you have a trick? Quote Link to comment
brudgers Posted January 15, 2010 Share Posted January 15, 2010 Ahh, a good point, Miguel! Off the top of my head, I can't devise a routine to scale an arc segment. Surely it is doable, but not obvious. (I might first make the arc 360?, then change the BBox, finally reset the original angles. Off the top of my head?) Once you sweep an arc object 360 degrees it becomes a circle object according to the OIP. Quote Link to comment
brudgers Posted January 15, 2010 Share Posted January 15, 2010 Try this as a starting point. http://techboard.vectorworks.net/ubbthreads/ubbthreads.php?ubb=showflat&Number=94550&Searchpage=1&Main=20191&Words=scale&Search=true#Post94550 The dynamic array of handles is a good idea. Quote Link to comment
Kool Aid Posted January 15, 2010 Share Posted January 15, 2010 Did either of you try SetBBox on circles? I did before I posted last night and it does not work. It does work on ovals, but not on circles. Do you have a trick? It doesn't? Not even on arc segments? (Should test myself, I know!) Well, blimey! Quote Link to comment
MullinRJ Posted January 15, 2010 Share Posted January 15, 2010 Use: ???hScale2D(H, Xcen, Ycen, ScaleF, ScaleF, False); Raymond Quote Link to comment
Pat Stanford Posted January 15, 2010 Share Posted January 15, 2010 I just tried SetBBox on an arc and it does not change. The VS Doc says: Procedure SetBBox positions objects whose geometry is defined by a bounding box. These objects currently are Image, PICT, Rectangle, Oval, Rounded Rectangle, and Worksheet Container. Ray, Do you know when the HScale functions were added? I am pretty sure they are farily new and were not there when I wrote my scale objects script in 2007. Quote Link to comment
brudgers Posted January 15, 2010 Share Posted January 15, 2010 HScale2D http://developer.vectorworks.net/index.php?title=VS:HScale2D Available from all versions. Quote Link to comment
Kool Aid Posted January 15, 2010 Share Posted January 15, 2010 No, it doesn't! As comes to HScale: what HScale? Not documented? An excerpt from VW2010 VS Function Reference: GroupToMesh H HAngle HArea HasConstraint HasDim HasPlugin HCenter HDuplicate Height HExtrude HHeight Hide HideClass HideLayer HLength HMove HMoveBackward HMoveForward HPerim HRotate HUngroup HWallHeight HWallWidth HWidth I ImportResourceToCurrentFile Quote Link to comment
brudgers Posted January 15, 2010 Share Posted January 15, 2010 The 2010 VS function reference?...that's adorable. Quote Link to comment
MullinRJ Posted January 15, 2010 Share Posted January 15, 2010 Hi Pat, ???hScale2D - born on version - VW 10 ???hScale3D - born on version - VW 12 I recently went through the VS Func Refs and the "backwater documentation*" to determine when things appeared (and disappeared). This was a little OC on my part, but good info if you really want to know. Raymond * VWPluginLibraryRoutines.p, in the user's plugin folder. Quote Link to comment
VectorBub Posted January 16, 2010 Author Share Posted January 16, 2010 (edited) I appreciate the help. Thanks. With circles, "scale (x, y)" would probably work well.As it happens, I need to increase the radius of all circles by 2 mm, regardless of their size, so I'm not sure I can use the Scale function for this. A Scale function probably doesn't have an option for specific mm increase. I can't say for sure, however, because I can't locate any documentation on Scale. Where did you find that? The second alternative could work---but I don't like it. Entity names and stacking order aren't the problem. These circles have all manner of different attributes, so re-creating them would be a lot more work (I think) than just creating a new default circle. I'd like to find a way to edit the radius of the existing circles, if possible. (I don't think density enters into the matter.) Edited January 16, 2010 by VectorBub Quote Link to comment
VectorBub Posted January 16, 2010 Author Share Posted January 16, 2010 The (documented) Object Variables are listed in the Additional Resources of VS Reference. There's no such thing as an ObjectAttributeReal. Get/SetBBox should work in your particular case. You're correct. I meant to say "GetObjectVariableReal". The Annotated Function Reference says: VS:GetObjectVariableReal FUNCTION GetObjectVariableReal(h:HANDLE;index:INTEGER):REAL; Parameters: h HANDLE Handle to object. index INTEGER Object property index. Where do I find the "Additional Resources of VS Reference"? Are the Object Variables listed there, and is that what is meant by Object property index? Quote Link to comment
Kool Aid Posted January 16, 2010 Share Posted January 16, 2010 A link to additional resources is in the top left frame of the VSFR. That opens another frame with the VectorScript Appendix. Documentation of HScale is on the VW Developer site There are almost 200 VS-functions there that are not included in the ref guide that comes with VW (ie. almost 1700 functions?) It is surprising that there isn't a function to change the radius! Since I do mainy parametric objects, I had not realised it. You can calculate the scaling factor using GetBBox. Quote Link to comment
MullinRJ Posted January 16, 2010 Share Posted January 16, 2010 (I don't think density enters into the matter.)????????Matter without density, now there's an interesting concept. VectorBub, A Scale function probably doesn't have an option for specific mm increase. ???You are right, so you should build your own. To add a fixed amount to a circle, you need to know its starting diameter. The ending diameter is the starting diameter + 2 * (radius increment). ???A nice way to implement this is by defining a function that accepts an increment and returns a scale factor; This is especially useful since your circles do have different diameters. function GetScaleFactor (H :Handle; RadiusInc :Real): Real; { Return the scale factor needed to change a circle's diameter by a fixed amount. } Var ???StartDiam, EndDiam :Real; ???X1, Y1, X2, Y2 :Real; Begin ???GetBBox(H, X1, Y1, X2, Y2); ???StartDiam := X2 - X1; ???EndDiam := StartDiam + 2 * RadiusInc; ???GetScaleFactor := EndDiam / StartDiam; End; { GetScaleFactor } ???To use it, you already have the center XY from hCenter: hCenter (H, X, Y); ScaleF := GetScaleFactor (H, 2mm); hScale2D (H, X, Y, ScaleF, ScaleF, False); ???Watch your units. Other than that, this will work every time. Raymond Quote Link to comment
brudgers Posted January 16, 2010 Share Posted January 16, 2010 I appreciate the help. Thanks. With circles, "scale (x, y)" would probably work well.As it happens, I need to increase the radius of all circles by 2 mm, regardless of their size, so I'm not sure I can use the Scale function for this. A Scale function probably doesn't have an option for specific mm increase. I can't say for sure, however, because I can't locate any documentation on Scale. Where did you find that? The second alternative could work---but I don't like it. Entity names and stacking order aren't the problem. These circles have all manner of different attributes, so re-creating them would be a lot more work (I think) than just creating a new default circle. I'd like to find a way to edit the radius of the existing circles, if possible. (I don't think density enters into the matter.) You could calculate the new scale. On the other hand if you don't need to maintain names...this would be common...you could call the offset tool. 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.