Jump to content

MullinRJ

Member
  • Posts

    2,004
  • Joined

  • Last visited

Everything posted by MullinRJ

  1. 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
  2. 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
  3. 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);
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. This could also be done with a VectorScript Tool or Menu Command Raymond
  10. 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
  11. 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
  12. They are MIA. Did you just spoil someone's Xmas present? Raymond
  13. 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
  14. 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
  15. Will, Because you didn't post a code example or the error you are getting I can't address your issue directly. More information is always better than less. On a general note, when you encounter an undocumented function that contains three similarly named variables with an XYZ last character, and those variables are declared as type REAL, if you get compiler errors, try using a single variable of type VECTOR instead. The online documentation shows the following, which is not only suspect, but syntactically wrong: FUNCTION RelativeCoords( ?????ptX, ptY, ptZ??:REAL; ?????begPtX, begPtY, begPtZ??:REAL; ?????endPtX, endPtY, endPtZ??:REAL) X, Y, Z :REAL; It should read: FUNCTION RelativeCoords( ?????pt??:VECTOR; ?????begPt??:VECTOR; ?????endPt??:VECTOR) :VECTOR; If you examine the EXAMPLE code posted on the same page you cited, you can see this is true. RelativeCoords() was introduced in VW11. As long as you are using a version of VW newer than that you will be able to compile this command. If you need help using VECTORS, write back and I or someone else will elaborate. Also, please create a signature with your computer specs and VW version. This helps others provide better answers. Raymond
  16. Use GetFldName() and GetFldType() on the Plugin record. Keep looking until you can't find any more. Raymond
  17. GetSymLoc(); returns document units, at least in every program I've ever written. I'm not sure why your numbers are off by a scale factor of 10. I think you'll need to look elsewhere. Some functions do return mm only. For those that do, you can scale them to document units with: Val_In_Doc_Units := Val_In_mm * GetPrefReal(152) / 25.4; Raymond
  18. Hello Carl, ???To make your script stop, you need to put the NextSObj() command inside the WHILE loop, as such: BEGIN ???h:=FSActLayer; ???WHILE (h <> NIL) DO BEGIN ??????{at this place follows the code that I used to generate the custom space tool} ??????h:=NextSObj(h); ???END; END; HTH, Raymond
  19. They do work, but there is also: SetObjectVariableReal(handle, 101, SymScaleType); where SymScaleType sets the way the ScaleFactors are applied. 0 = None 1 = Symmetric 2 = Asymmetric Raymond
  20. Epic. Thanks for the link. Did you check out the next day's Dilbert? It got audible giggles from me. http://dilbert.com/strips/comic/2007-09-18/ Raymond
  21. Vincent, ???Though I don't disagree with your request for a better interface, the names of the viewports you show in your screenshots are displayed at the BOTTOM of the OIP. Not the most obvious place to catch your eye, and you still have to switch to the DATA pane to change them, but they do display when selected, just not prominently. Raymond
  22. Mike, ???Have you tried : GetFileInfo()? I'm not sure how it will treat .sta files, though, since they are dissociated from the disk file when they are opened. Raymond
  23. Try: CreateText(GetObjectVariableString(GetLayer(ghObject), 162)); You can trim off the parts you don't want with the delete() and pos() functions. Raymond
  24. One more thing before I quit for the night, LObject points to the last object in the drawing, which is always on the topmost layer. LActLayer points to the last object on the active layer, which is what I'm guessing you want. If you are working in a one layer drawing or you are on the top layer, they will be equivalent. But what are the odds that will work to your favor? Raymond
  25. Michael, ???Your loop counters are going from 1 to 0; i.e., not looping. The variables QtyRecordFormats and QtyFields are uninitialized, so they are 0 at the start of the loop. Change QtyRecordFormats to NumRecords(OldSym) and QtyFields to NumFields(CurrentRecord) But I have a question about your record copying, aren't all the records being duplicated with hDuplicate()? And they stay intact after SetHDef(). What are you trying to copy that isn't already there? Raymond
×
×
  • Create New...