Jump to content

Julian Carr

  • Content Count

  • Joined

  • Last visited

Everything posted by Julian Carr

  1. Anyone know why this code: Procedure T; VAR s1 : STRING; BEGIN s1 := Concat(GetFolderPath(1), 'Test.txt'); ReWrite(s1); WriteLn('test'); Close(s1); END; Run(T); works fine on a Mac but returns this error on a PC: Error on line=6: T S1 - File operation returned error. Error on line=8: T S1 - Bad file name. C:\Program Files\Vectorworks 2018\Test.txt Thanks!
  2. Thanks Nicolas. Yes I tried a few different combinations including this: {$INCLUDE MessageScriptTesting/MessageScript.vss} but none of them worked.
  3. Thanks again Nicolas. Unfortunately I can't get it to work. A full path such as this will work: {$INCLUDE /Users/juliancarr3/Desktop/MessageScriptTesting/MessageScript.vss } but then something like this (or variations thereof), does not work: {$INCLUDE /MessageScriptTesting/MessageScript.vss } The Vectorworks file with the saved views is also in the MessageScriptTesting folder. The following also doesn't work on the Mac which is unusual because I normally use backslashes in include names: {$INCLUDE \Users\juliancarr3\Desktop\MessageScriptTesting\MessageScript.vss }
  4. Thanks for the suggestion Nicolas. Do you know if there is any documentation on how to create relative paths?
  5. We are using a lot of saved views in our training and have added a script to each saved view to open the message window with some instructions that pertain to each particular step. This allows users to be able to work in the file while still having the instructions visible and unaffected by view changes, panning or zooming. The notes for each of the message strings come from a worksheet within the file. There are two things that would make this process better. 1. Being able to get the name of the current saved view that is running the script. 2. Being able to access the script via an include file. Can anyone think of a way to do either of these things? Because we run training courses at a 3rd party training venue, we generally can only install the training files in a folder on the Desktop of each machine, so the potential path to any include file will be different on each machine. Thanks for any ideas. Julian PS. I discovered that you can get around the limitation of 256 characters in a message, by concatenating a series of sub 256 character strings together within the message call.
  6. Move3DObj() is definitely the one to use. Call it right after EndXtrd; I use this extensively in exactly the same context.
  7. Dunno Sam. Maybe is it working of the active layer and not the layer you specify. Try making each layer active before getting the layer into. If you do this, then you only need to use GetDrawingSizeRect() which returns info from the active layer.
  8. Scale factor is only there to demonstrate the script. If you run the script with the default setting, it should make the page size 1.5 times larger. If you are the only one using your script then I agree units should not be an issue. If it is anyone else, then the values you are storing should have unit marks so they allow for it. People will always to the unexpected.
  9. It works for me Sam. Try this script as a test: Procedure T; VAR x1, y1, x2, y2, ScaleFactor : REAL; BEGIN ScaleFactor := RealDialog('Scale Factor:', '1.5'); GetDrawingSizeRectN(ActLayer, x1, y1, x2, y2); SetDrawingRect((x2 - x1) * ScaleFactor, (y1 - y2) * ScaleFactor); Message((x2 - x1) * ScaleFactor, chr(13), (y1 - y2) * ScaleFactor); END; Run(T); Make sure you get the units right tool. Can't remember if it uses document units, mm or inches.
  10. You can use GetDrawingSizeRect() to establish the current page size, and SetDrawingRect() to set a new page size.
  11. Thanks Josh. I had a bit of a play with it but as you implied, it makes Vectorscript even more of a black box than it is already. Lots of unexplained crashes and mystery. Two things I have built up immunity to over the years, but I still got the bug with this one.
  12. Does anyone have a sample script for a VST that uses buttons in the tool bar? Thanks!
  13. Well blow me down Pat - thanks. I need to get out more.
  14. You will need something like this, which only counts object whose parent is a layer: PROCEDURE xxxxx; VAR gNumObjects : INTEGER; Procedure CountThem(h1 : HANDLE); BEGIN IF GetType(GetParent(h1)) = 31 THEN gNumObjects := gNumObjects + 1; END; BEGIN gNumObjects := 0; ForEachObject(CountThem, (Sel = True)); Message(gNumObjects); END; RUN(xxxxx);
  15. really? I just assumed they had to be Python as all the default ones were so. That opens a lot more possibilities. Thanks Pat.
  16. Thanks Pat and Josh. I think Josh has nailed it with his last suggestion, which seems to work with any units. The script I am working on is for a worksheet and will populate a single cell with all the door IDs that match a particular door type (and optionally width), comma separated. A door type could be an internal door, an external door, the front door of an apartment, or a patio door of a particular style. Sometimes the doors can vary in size but are otherwise the same type. Something like this: TYPE ID WIDTH ETC | Type A | D01, D04, D07 | 1000 | | | Type A | D02, D03, D05 | 900 | | | Type B | D06, D11, D12 | 1000 | | | Type B | D08, D09, D13 | 900 | | The RunScript() function is so powerful it has prompted me to dip my toes into the python pit.
  17. I have never been able to get things like OPTION, COMMAND, etc to work, however I recall using AUTOKEY in some scripts successfully. It would be good to have reliable modifier key support.
  18. Thanks for the suggestion Josh. Unfortunately it doesn't work as the string remains in scientific notation. If you draw a Space object in a file with units set to mm then run this script: perimValueStr = vs.GetRField( vs.FSActLayer(), 'Space', 'Perim' ) repr(float(perimValueStr)) crit_ = "('Space', 'Perim' = "+ perimValueStr + ")" vs.Message(crit_) you will get this result: ('Space', 'Perim' = 6.4e03) If the units are changed to Ft & Ins, then it doesn't work at all and produces an error (could not convert string to float) as the notation value is too long.
  19. I totally agree Pat. Even though Pascal is verbose compared to Python and doesn't have the same community support or external libraries, it requires special knowledge to understand the syntax. Anyway thanks to you I figured a way to do it, though it only works with files in metric units. If you draw a Space, leave it selected the run this script, you will see the desired criteria string: perimValueStr = vs.GetRField( vs.FSActLayer(), 'Space', 'Perim' ) (Flag, perimValue) = vs.ValidNumStr(perimValueStr) #convert notation string to real number perimValueStr = format(perimValue, '.4f') #convert real back to string to 4 decimal places crit_ = "('Space', 'Perim' = "+ perimValueStr + ")" vs.Message(crit_)
  20. Nice try Pat. It still produces an error. It doesn't like the 'f'. Run this snippet to see it: widthValue = '9e02' format(widthValue, 'f') vs.Message(widthValue)
  21. Well I guess you are correct Pat, and thanks for your reply. It is already a number expressed in scientific notation, but that can't be used in a criteria string. This is the error it gives: Error: Unable to parse Search Criteria. Database(('Space'.'Perim' = 9e02)) so I need a way to change this: perimValue = 9e02 to this: perimValue = 900 Any ideas on that one?
  22. Sometimes when you use GetRField() to return a dimension value from a PIO, it returns the value in scientific notation, so a value of 900 (mm) becomes 9e02. You can use Str2Num('9e02') to convert this to a real number, however this does not work in python and produces this error: Type Error. Can't convert 'float' object to str implicitly. Here is a code snippet: perimValue = vs.Str2Num(vs.GetRField( h, 'Space', 'Perim' )) crit_ = "('Space'.'Perim' = "+ perimValue + ")" vs.ForEachObject(DoIt, crit_) The equivalent in Vectorscript works OK. Thanks for any ideas. Julian
  23. I think I worked it out but the result is odd. Using GetVectorFill() you can get the name of the fill. Then using GetType(GetObject(FillName)), you get the object type as follows: Hatch: 66 Tile: 108 Image: 119 Gradient: 120 Here is the test code I used, which works on the fill of the selected object: Procedure T; VAR h : HANDLE; s1 : STRING; n : LONGINT; Flag : BOOLEAN; BEGIN h := FSActLayer; n := GetFPat( h ); s1 := Index2Name(n); Flag := GetVectorFill(h, s1); message( n , ' ', s1, ' ', GetType(GetObject(s1))); END; Run(T);
  24. Anyone know how to get the type of fill (hatch, tile or image) associated with an object? I know that GetFPat() will return a negative number for these fill types and you can get the name of the fill using GetVectorFill(), however this doesn't give you the fill type. There must be a way?? Thanks, Julian
  25. This works for me in many cases: FOR i := j DOWNTO 0 DO RemoveChoice(gDialog1, 29, i); Perhaps you need to go backwards? Julian


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...