Jump to content

Julian Carr

Distributor
  • Content Count

    172
  • Joined

  • Last visited

Everything posted by Julian Carr

  1. Thanks Nicolas. Yes I tried a few different combinations including this: {$INCLUDE MessageScriptTesting/MessageScript.vss} but none of them worked.
  2. 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 }
  3. Thanks for the suggestion Nicolas. Do you know if there is any documentation on how to create relative paths?
  4. 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.
  5. Move3DObj() is definitely the one to use. Call it right after EndXtrd; I use this extensively in exactly the same context.
  6. 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.
  7. 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.
  8. 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.
  9. You can use GetDrawingSizeRect() to establish the current page size, and SetDrawingRect() to set a new page size.
  10. 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.
  11. Does anyone have a sample script for a VST that uses buttons in the tool bar? Thanks!
  12. Well blow me down Pat - thanks. I need to get out more.
  13. 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);
  14. really? I just assumed they had to be Python as all the default ones were so. That opens a lot more possibilities. Thanks Pat.
  15. 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.
  16. 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.
  17. 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.
  18. 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_)
  19. 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)
  20. 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?
  21. 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
  22. 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);
  23. 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
  24. This works for me in many cases: FOR i := j DOWNTO 0 DO RemoveChoice(gDialog1, 29, i); Perhaps you need to go backwards? Julian
  25. The only way to achieve this would be to move the symbol instance into the profile group of the PIO, then copy the 3D components from that symbol instance into the PIO. You could do this by cycling through all the objects in the symbol, duplicating anything that is 3D (use GetType()), then using SetParent() to move it from there to the PIO. If the symbol contains planar objects, then you will also need to check if 2D objects are planar and if so, duplicate and move them as well. 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...