Jump to content

MullinRJ

Member
  • Posts

    2,015
  • Joined

  • Last visited

Everything posted by MullinRJ

  1. Or try: scaleX := NewXValue/ OldXValue; scaleY := NewYValue/ OldYValue; HScale2D(h: HANDLE; centerX, centerY, scaleX, scaleY: REAL; scaleText: BOOLEAN); where (centerX, centerY) is your XY anchor point. In the case of a RRect, the corner radii will scale, too. You'll have to reset them with: GetRRDiam(H, XDiam, YDiam); and SetRRDiam(H, XDiam, YDiam); Raymond
  2. I have noticed on my macMINI that the CPU can jump to 100% usage when doing things in VW anytime the RB is closed. Running scripts is often the culprit. Opening the RB will quiet the beast. So, it's not only an issue of the RB state at VW startup, it can happen any time the RB is closed. The good news is the fix is easy. Open the RB. Raymond
  3. Short answer: Use OR instead of AND. Longwinded answer: SelectObj() is going through a list of objects one at a time and selecting any object that meets, in your case, both criteria (Rect AND Oval). Since an object cannot be a RECT and and OVAL at the same time, you want the OR operator, instead of the AND operator. You want to select any object that is either a RECT OR an OVAL. This will work for selecting all RECTs and OVALs: SelectObj((T=RECT) OR (T=OVAL)); Raymond
  4. Derek, ???My Reshaper script uses 55 include files. Perhaps it's a RAM issue, or maybe an OS issue. No problems on this end. Raymond
  5. Also be aware that characters in the upper 128 ASCII range will show differently on Mac and PC, regardless of how they are generated or recalled. Raymond
  6. Wouter, ???Did you use CreateCheckBox() or CreateThreeStateCheckBox()? Raymond
  7. Michael, ???You are missing a parenthesis of the right handed variety; or, you have included an extra parenthesis of the left handed variety. I prefer to favor the latter explanation as I usually prefer more concise expressions, but making either adjustment will improve your code's execution. Raymond
  8. Hi Kevin, ???I'm not sure about the PC. It does work on the Mac. OK, I just tested on the PC - chr(13), chr(10) works on the PC in the Message window. Raymond
  9. The last few versions of VW will handle chr(13). This is a very nice feature. You may have to resize the Message window manually to see additional lines. Raymond
  10. In the meantime, you can create a new layer above the current layer, or above all layers, and place objects there that NEED to be on top. With a script you can toggle that layer on and off as needed. Place the script into a Menu Plugin, assign a hot key to it, and you try not to get pulled over by the Edit Police. I do this in reverse with a grid and label layer that resides on the bottom of the view order that I toggle its visibility as needed. If you want this feature for multiple layers, a script can detect what layer is currently active and toggle the visibility of its complementary layer. Saved Views can also be used to turn on layer pairs that need this functionality. It's not a bad idea, but it's all doable right now; or you can wait for the feature to get implemented. Raymond
  11. Pietro, ???When two consecutive polyline vertices are non-CornerPoints (eg., Arcto-Arcto, Arcto-Bezier, Arcto-Cubic, Bezier-Cubic, Bezier-Bezier, or Cubic-Cubic) then the midpoint between them will limit the maximum curvature of those two vertices. ???The way to increase the curvature at your problem vertex is to explicitly add a corner point between the two close Arcto points and slide it away from the larger radius vertex and toward the smaller radius vertex. Add the bold line to your code as shown to increase the radius of the sixth node: ??ArcTo(31.123124276903400, 11.818491333769316, 3.0); ??LineTo(31.1231242769034, 6.0); ??ArcTo(31.123124276903400, 3.275635883435621, 2.0); ???Now, with your polyline selected, when you hover your cursor over the polyline with the Reshape tool, you can see where the ends of the Are segments lie on your curve. Notice the new point lies between the two arcs on either side. HTH, Raymond
  12. Peter, ???I tried your script and even with Kevin's fix, your script completely replaces the selected text blocks with with your numbering sequence. If you want to prepend your text blocks with your numbers, you'll want to change this line: ?????NewStr := BaseVal; at the end of MakeTxt() to: ?????NewStr := concat(BaseVal, OldStr); ???Also, in an undisclosed future version of VW, the code that creates the dialog will cease to work and will have to be replaced with similar code that uses Modern Dialog code. But for now, this script will work up to and including VW 2013. Raymond
  13. That's correct. The reason the main body has no variables is because ForEachObject() uses an internal handle variable to pass the Space objects to the RoundSpaceDimensions() procedure. RoundSpaceDimensions() has to accept one HANDLE variable. No other variables are required at the main level. All the other variables you use are declared inside the other procedures and are local to those procedures. You could declare them all at the global level, but your program reads better if they are declared locally. Enjoy your programming. It gets easier and fun(er) with practice. Until next time, Raymond
  14. Michael, ???Because you run the same code to round off each dimension for the space object, I would make that piece a separate function. Typically, if code is used more than once, it can be turned into a PROCEDURE or FUNCTION. This shortens your code and usually makes it more readable. ???I rewrote your code as an example. In this case, it also shortens your variable list considerably. Notice, you now have no global variables as they are all local variables in their respective procedures. If you have any questions about it, please ask. HTH, Raymond Procedure SpaceDimInUser1and2; {Badly scripted by Michael Klaers} {January, 2013} {? 2013, Small Group, Inc - Michael Klaers michaelk@verysmallgroup.com} {Licensed under the GNU Lesser General Public License} {Gets the dimensions of all space objects, rounds them to the nearest foot, and places them in user field 1 and 2} PROCEDURE RoundSpaceDimensions(SpaceHand :HANDLE); VAR xWidth, xLength, roundedWidth, roundedLength : String; FUNCTION RoundIt(Num :String) :String; Var ExpMarker, NumLength, roundedVal :Integer; Exp, Base :String; BEGIN { RoundIt } ExpMarker := POS('e', Num); NumLength := LEN(Num); Exp := COPY(Num, ExpMarker+1, NumLength-ExpMarker-1); Base := COPY(Num, 1, ExpMarker-1); roundedVal := ROUND((Str2Num(Base) * 10^Str2Num(Exp))*1000); RoundIt := CONCAT(roundedVal, ''''); { This is your string to stuff into a record field } END; { RoundIt } BEGIN { RoundSpaceDimensions } xWidth := GetRField(SpaceHand, 'Space', 'Width'); roundedWidth := RoundIt(xWidth); { This is your condensed function } SetRField( SpaceHand , 'Space', '11_User-Def Info 1', roundedWidth); xLength := GetRField(SpaceHand, 'Space', 'Length'); roundedLength := RoundIt(xLength); { This is your condensed function } SetRField( SpaceHand , 'Space', '11_User-Def Info 2', roundedLength); ResetObject(SpaceHand); END; { RoundSpaceDimensions } BEGIN ForEachObject(RoundSpaceDimensions, (PON='Space')); END; RUN(SpaceDimInUser1and2);
  15. Uwe, ???You may have a problem. I posted my results using Maarten's script and VW 2013 and it works. I tried the same script in VW 2012 back to VW 2009 and it does not work in any of them. I think this is a bug that was fixed in the latest version and there may not be a workaround in earlier versions. Apologies for any false hope. Raymond
  16. Maarten, ???When I run your script, both ROOT1 and ROOT2 are expanded. Changing TRUE to FALSE in ExpandTreeControlItem(dialog1, 4, 0, FALSE); collapses ROOT1. To collapse ROOT2 another line would be needed. ExpandTreeControlItem(dialog1, 4, root2, TRUE); ???In this example, root2 = 3, as it is the fourth item in the list and the list starts counting at 0. Uwe, ???In your example, assuming you used "4" as the dialog item number for your tree in: CreateTreeControl(dialog1, 4, widthInChars, heightInChars); try: ExpandTreeControlItem(dialog1, 4, 7, FALSE); HTH, Raymond
  17. Hello Huy, ???Here is a very short script that will get the XYZ coordinates of the center of a selected 3D object and display them in a Dialogue Box. There is no Set3DCenter() function in VectorScript (sadly), but you can use hMove3D() to slide the object into any position you want (with a little arithmetic). PROCEDURE xxx; { Get the 3D Center values of the first selected object and sheo them in an Alert Dialogue Box.} CONST CR = chr(13); { Carriage Return character } VAR Xcen, Ycen, Zcen :Real; S :String; BEGIN Get3DCntr(FSActLayer, Xcen, Ycen, Zcen); { Concat() builds a string from parts and also changes numbers to strings. } { String S holds the answer that will display in the dialogue box. } S := concat('X center = ', Xcen, CR, 'Y center = ', Ycen, CR, 'Z center = ', Zcen); AlrtDialog(S); END; Run(xxx); Raymond
  18. Hi Joshua, ???I'm pretty sure you can't force the EAP to generate before your script ends, and I looked for a way to force it to a Generic Solid but found none. I still think the EAP would have to generate before it could be converted to a Solid. Maybe someone at the Mother Ship could confirm if this is all true. ???Use a Locus to set the center of rotation. Here's an example that draws your wall and moves it into position. { View must be TOP, or Top/Plan } BeginSweep(45, 90, 5, 0); { sweep center is (0, 0, 0) } Locus(0, 0); Rect(-62.5, 1000, 62.5, -1000); { profile center is (0, 0) } hMove(LNewObj, 2000, 0); { move profile right } EndSweep; SetRot3D(LNewObj, 90, 0, 90, 0, 0, 0); { stand sweep up and rotate 90 (z) } hMove(LNewObj, 0, -1800); { move sweep into plan position } Raymond
  19. Josh, After playing with this for an hour or so, I think your problem lies in the fact that the curved wall is an ExtrudeAlongPath (EAP) object, which is a Plugin Object. Though I am not versed in all the ins and outs of such beasts, you can add them with VS AddSolid() if it's run from a separate script. This leads me to believe that the EAP in your script does not exist until after your script finishes execution, and that has to do with the EAP's internal script running AFTER yours is done. Once both scripts finish, then you can add the objects with the AddSolid() command, but it has to be initiated in another script, which I'm sure defeats your whole purpose. Maybe a Sweep is better suited for this than an EAP. After your script creates your 3D objects, select them both manually and run this script: Procedure AddSolidTest; { Add the 1st two selected objects with AddSolid(). } VAR result :INTEGER; CurvedWall3D, PolyBHnd, SolidHnd :HANDLE; BEGIN CurvedWall3D := FSActLayer; PolyBHnd := nextSObj(CurvedWall3D); result := AddSolid(CurvedWall3D, PolyBHnd, SolidHnd); message('result = ', result); END; Run(AddSolidTest); This shows that AddSolid() will work on an EAP and an Extrude, but only after the EAP has finished generating. HTH, Raymond
  20. This could also be done with a VectorScript Tool or Menu Command Raymond
  21. Hello Wouter, ???The problem you are having is in matching the points in your diagram to the points you need in VectorScript to draw the shape. Your shape requires 6 points, not 4 ? the 4 you have on your diagram and 2 more to help define the arcs. ???The ARCTO points are virtual points and do not lie on your finished path. You got the first one right, but you did not follow the same method for defining the second ARCTO point ???One easy way to see how to draw a complex shape with VS is to draw it manually in a blank file, then use the Export VS... command under the File->Export menu. Open the text file with an editor. The object creation code is closer to the bottom of the file than to the top. ???Another thing that might make your procedure easier to write is to choose variable names that correspond to the physical parts of your shape; alwasy more difficult than it seems. I reworked your code example and changed some variable names, and added one to hopefully make the code easier to follow. Here's what I think you are trying to do. I labeled the points on your diagram as P1-P4 and I labeled the two ArcTo points as PA & PB. This code only draw a 90? section. Different angle sections can be drawn, but more math is needed to get the ARCTO points defined. PROCEDURE xxx; { This code sample will draw a 90? cross section of a pipe wall. } CONST HorOffset = 5; { was your LENGTH } Thickness = 3; { was your DIAMETER } InnerRadius = 2; OuterRadius = Thickness + InnerRadius; BEGIN ClosePoly; BeginPoly; {P1} AddPoint(HorOffset, Thickness/2); {PA - the ARCTO point is not on the path, it is a point that is on both tangent lines through P1 & P2.} ArcTo(HorOffset + OuterRadius, Thickness/2, OuterRadius); {P2} AddPoint(HorOffset + OuterRadius, -Thickness/2 - InnerRadius); {P3} AddPoint(HorOffset + InnerRadius, -Thickness/2 - InnerRadius); {PB - the ARCTO point is not on the path, it is a point that SHOULD BE on both tangent lines through P3 & P4.} ArcTo(HorOffset + InnerRadius, -Thickness/2, InnerRadius); {P4} AddPoint(HorOffset, -Thickness/2); EndPoly; END; Run(xxx); ???It is also possible to draw the shape with a 3-Point-Arc method. Here's another example, but without your variables. The points are hard coded. PROCEDURE xxx; { Example using PointOnArc method, or 3-Point Arc to draw a 90?cross section of a pipe wall } BEGIN ClosePoly; BeginPoly; { P1 } MoveTo(0, 4); { PA - point on the arc between P1 and P2 } Add2DVertex(2.82842712474619, 2.828427124746191, 4, 4); { P2 } LineTo(4, 0); { P3 } LineTo(2, 0); { PB - point on the arc between P3 and P4 } Add2DVertex(1.414213562373095, 1.414213562373095, 4, 2); { P4 } LineTo(0, 2); EndPoly; SysBeep; END; Run(xxx); HTH, Raymond
  22. You need more data to define the direction and radius of the arcs. How else will VS know to draw a CW or CCW arc segment? Three points on the arc segment, or two points and a radius are typical inputs for your function. Raymond
  23. They are MIA. Did you just spoil someone's Xmas present? Raymond
  24. Most of the constants are in the Appendix of the VS Function Reference. There is an online version at: developer.vectorworks.net Other constants can be found in the SDK. Still others can only be found by asking the engineers at NV. Raymond
  25. I believe SetPref(1099, True); sets the mode to Screen Plane. False sets it to Layer Plane. If you save the value before you start, you can restore it when you're done. HTH, Raymond
×
×
  • Create New...