Jump to content

MullinRJ

Member
  • Posts

    2,007
  • Joined

  • Last visited

Everything posted by MullinRJ

  1. Contrary to popular belief, CAD always requires a brain. Sometimes a little prompting is all it takes to get it on track. When you set your datum, tab into the X & Y fields to enter your data and not the Delta X & Y fields. The Datum sets your new (0, 0) point and X & Y are now relative offsets to the new datum. The Delta X & Y fields will always refer to the segment you are drawing which is always relative to the last point you added to your Poly. Don't forget to tab out of the field(s) you are typing into to get your data to stick. HTH, Raymond
  2. Wouter, ???Would something like this work to find out how many Elements there are of each name? Of course, this is totally untested code. Just a thought in passing. Function CountElements(Hxml :Handle; LMNTName :String) :Integer; Var ???Done :Boolean; ???I, Rslt :Integer; ???LMNT, Val :String; Begin ???I := 0; ???Done := False; ???while not Done do begin ??????I := I + 1; ??????LMNT := concat(LMNTName, '[', I, ']'); ??????Rslt := GetElementValue(Hxml, LMNT, Val); ??????Done := Val = ''; ??????Done := Rslt <> 0;???{ maybe this test would work better } ???end;??????{ while } ???CountElements := I - 1; End;??????{ CountElements } HTH, Raymond
  3. There is a difference between Concat and Num2Str, basically format control. Num2Str will let you set the number of decimal places you see from 0 to 10. Concat will show all decimal digits (up to 15 if they exist). Both are useful in their own right. Raymond
  4. Derek, if you convert the number to a string and display that in the OIP you can remove the units with Num2Str(). Raymond
  5. Maybe it's not that simple? Glib remarks aside, I believe you are working with the shadow and not the object causing the shadow. T=56 is the image of a Worksheet placed in the drawing. It is like a symbol instance compared to a Symbol Definition. T=18 is the actual Worksheet. I haven't vetted any of your subsequent thinking, so this isn't a complete answer, but I'd try working with the actual Worksheet "definition". HTH, Raymond
  6. Try: ???PROCEDURE ABC(H :HANDLE); ???Begin ???End; BEGIN ???ForEachObject(ABC, (T=56)); END; Raymond
  7. Tui, ??If I may add to what Josh said: ?Josh is mostly right, but there's a gray area. The value of a handle does not change at random, or after a script is run. It exists as long as the VW file is open. ???A handle to an object holds an unique number. You can see the number using the MESSAGE() command, if you like. You can't modify a handle's value, but you can view or test it to see if it changes. ???Try a script with the line: Message(FSActLayer); ???Move the object, stretch it, change its color, send it forward or back, send it to another layer (w/ the OIP). Each time you do something rerun the script. Now CUT the object and PASTE it back again. Rerun the script. It now has a new handle. ???As long as your file remains open, the value of a handle does not change unless you (or VW) modify the object in such a way that results in a change. Some operations will change handle values, like Add Surface, and Cut/Paste; while others will not, like Move, Scale, and Rotate. ???Over the long haul, handles are temporary. When you close then reopen a file, VW assigns new handle values to every object, so you cannot use stored values of handles for long term reference. Over the short haul, it works. ???In summary: You can store handle values between running a script once and then running it again or running another script, or editing the file. If the objects are still there, their handles are, too. When you close the file, the handle values will be different when the file is reopened. Raymond
  8. Yes, the benefit comes when you want to call the code again. If you were only adding four polys once, then you wouldn't need make a function. But if you were going to use this approach in another program you had planned, then there might be a benefit to making a function. It's a judgement call. Typically, I write everything inline, then when I see a pattern in the code that looks like a complete thought I make a function/procedure of it. It is a learned habit. If you write enough code, you will have an idea when it will serve you best. It usually does make your code easier to read. No legal reasons, except maybe ownership. This forum has a place near the bottom of the front page "Vectorworks Resource Share - VECTORSCRIPT" where people do share examples. This section is more for problems, but examples are welcome and you will always get helpful comments to requests for improvement. All the best, Raymond
  9. Tui, ???A function is a user defined set of VS commands that can be called in your main program as a single statement. Functions can also be nested, so they can be very complicated, but if they are well written, they will make you code easier to follow. The reason you write functions is to simplify your program by putting commands together that perform a higher level operation, and at the same time make your program more readable. ???Without a function, your idea to add 4 polys together might look like this (with handles JkTopC, JkBotC, JkLeftC, and JkRightC that point to four different polygons): AddPolyHnd := AddSurface(JkTopC, JkLeftC); AddPolyHnd := AddSurface(AddPolyHnd, JkBotC); AddPolyHnd := AddSurface(AddPolyHnd, JkRightC); ???It is assumed that all the polys overlap to some degree, so the order of addition is not important. ???A function to do the same thing might look like: FUNCTION Add4Polys(PolyH1, PolyH2, PolyH3, PolyH4 :Handle) :Handle; VAR ???RsltPolyH :Handle; BEGIN ???RsltPolyH := AddSurface(PolyH1, PolyH2); ???RsltPolyH := AddSurface(RsltPolyH, PolyH3); ???RsltPolyH := AddSurface(RsltPolyH, PolyH4); ???Add4Polys := RsltPolyH;??????{ This is the return value } END;??????{ Add4Polys } ???To use the function in your code you would create all your poly objects and assign them to handle variables like you did before, and then call your function with: ... ???AddPolyHnd := Add4Polys(JkTopC, JkBotC, JkLeftC, JkRightC); ... ???This is very basic and does not cover all possible combinations of events, like two polys do not touch so they do not add, or one poly did not get created so its handle is NIL before you start. A well written function will contend with these possibilities so the code won't bomb at runtime if something goes wrong. It may even post a message alerting the user that something unexpected happened. ???There are different forms of user defined FUNCTIONS. If a function does not generate a return value it is a PROCEDURE. Both procedures and functions can have arguments that are variable, meaning the variables that are passed to the function can be changed by the function and will stayed changed when the function finishes. ???See any book on PASCAL Programming for more and better examples. Also read the VectorScript User Guide which explains differences in VectorScript from standard PASCAL. HTH, Raymond
  10. Yes. You will have to add them together 2 at a time. Are you always adding the same number of shapes? Or a known set number of shapes? If so, you can write a function that takes all of their handles and will combine them. If the number of shapes has an unknown upper limit, then I'd suggest storing your handles in an array (or DynArray) and process them from the array. Raymond
  11. If you select ONLY the objects you want added, you can use: DoMenuTextByName('Add Surface', 0); Raymond
  12. It sounds like you drew the base as an extruded rectangle. If the center of the rectangle was at (0", -0.75"), and it was extruded by 1/4", you would get the Center of Mass that you posted. (cX is effectively zero, 3.644x10^-18" == 0.) Your bar is already sitting on the ground (bottom Z = 0), as cZ is at 1/2 your thickness (0.25"/2). Extrudes always go up from the 2D object sitting on the ground. All you need to do is go to Top or Top/Plan view, select all, and move your part (0", 0.75"). It will then be sitting on the origin. Raymond
  13. From the VSFR for CreateExtrudeAlongPath: ???The path argument must be a handle to a NURBS Curve object (type 111). ???The profile argument must be a handle to an object of one of the following types: NURBS Curve, Polygon, Polyline, Arc, Rectangle, Rounded Rectangle, Line, Oval. Try the following: PROCEDURE SuperExtrPath; VAR p ,n, h :HANDLE; a, b :INTEGER; BEGIN p := FObject; { arc } n := NextObj(p); { rect } p := ConvertToNURBS(p, true); { arc -> NURBS, keep original } h := CreateExtrudeAlongPath(p, n); delobject(p); { delete NURBS path } END; RUN(SuperExtrPath); Note: The position of the final extrude relative to the path will be determined by the how far the center of the profile object is from the origin. Also, handle "h" only points to one surface of the final EAP. In your example, there are 6 NURBS surfaces in the result. You can count the number of objects before and after the operation and collect the top N objects (the difference in the counts) into a GROUP, a solid, or some other container if you want to process the EAP further. HTH, Raymond
  14. You'll have to have data in every field. VW read/write functions are not that sophisticated. Or, you'll have to read each line and count the number of delimiters in a row before valid data and offset your field assignments, (i.e., you'll have to parse the input strings manually.) Raymond
  15. Oops, I should have sent mine before I left the room. Same as Josh said.
  16. You can also create a function B2I (short for Boolean_To_Integer), which will return 1 for True and 0 for False. function B2I (Boo :Boolean) :Integer; { Return 1 for True and 0 for False. } Begin ???if Boo then?B2I := 1; End; Then, in your main program add them up with: Cnt := B2I(ChkA) + B2I(ChkB) + B2I(ChkC) + B2I(ChkD) + B2I(ChkE) + B2I(ChkF) + B2I(ChkG) + B2I(ChkH) + B2I(ChkI) + B2I(ChkJ); HTH, Raymond
  17. Paste your text into a simple text editor first, like TextEdit on the Mac or NotePad on the PC. Then copy from there and paste it into VW. This should fix the EndOfLine character(s) for the platform you are using. Raymond
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. Wouter, ???Did you use CreateCheckBox() or CreateThreeStateCheckBox()? Raymond
  24. 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
  25. 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
×
×
  • Create New...