Jump to content

MullinRJ

Member
  • Posts

    1,987
  • Joined

  • Last visited

Everything posted by MullinRJ

  1. Hi Charles, ???I would hope DEEP meant FEIOL would crawl into Folders as they are just another container type, but I don't know off the top of my head. Will check tomorrow. Zzzzzzz time now. Raymond
  2. Hi Pat, ???I believe my second FEOIL(ist) will look inside Symbols adequately, but I don't think my code will modify any PIOs containing text. They may need to be done manually, or with some knowledge which PIOs are used. ???I modified the function ChangeFont to test for text objects, an omission resulting from having a good thought and not acting on it before it evaporated. ???One assumption my code makes is that it judges the Font Face of a text block by its first character. If you mix Font Faces inside text blocks, then the code will need to be modified to check each character in each text block for the old font and change it accordingly. Not hard, just a little more tedious. Raymond
  3. Hi Matt, ???Actually, it's VS 102 and the fastest way to learn it is by example. This is untested code, so try it on a test file first and I'm sure you can make it work. It's a basic template you can use to make global changes to files and you can get as specific as you want with your matching criteria just by changing the logic in called function (ChangeFont, in this example). Raymond PROCEDURE SwapFonts; { Change the Font Face of every text object in a file. } { 09 Sept 09 - Raymond J Mullin } CONST Font0 = 'Tekton Pro'; Font1 = 'Tekton'; VAR H :Handle; FID0, FID1 :Integer; function ChangeFont(H :Handle) :Boolean; Var FID :Integer; Begin if (GetType(H) = 10) then begin FID := GetTextFont(H, 0); { font ID of text object - first character } if (FID = FID0) then SetTextFont(H, 0, len(GetText(H)), FID1); end; { if GetType } End; { ChangeFont } BEGIN FID0 := GetFontID(Font0); { original Font ID } FID1 := GetFontID(Font1); { new Font ID } ForEachObjectInLayer(ChangeFont, 0, 2, 1); { All objects, Deep, All layers } ForEachObjectInList(ChangeFont, 0, 2, FSymDef); { All objects, Deep, All symbol definitions } Sysbeep; { beep when done } END; Run(SwapFonts);
  4. orso, Though all you say is true, knowing these shortcomings, one can program around the problems, or avoid them altogether. Even partially impaired, the function works for a majority of cases. For my own uses, the function works quite well enough and I would not avoid using it. I don't think any of the problems are critical enough to not recommend it. Just use it with caution - Caveat Scriptor. Raymond
  5. This is what you want to use. filename := GetFPathName;??????{ poorly documented function } There is some info on this function here: http://developer.vectorworks.net/index.php?title=VS:GetFPathName HTH, Raymond
  6. Hi Jack, ???This won't do exactly what you want, but it will compile, it will run and it will show the values it collects. Raymond PROCEDURE xxx; CONST ??????CR = chr(13);??????{ Carriage Return } VAR ??????dateValue, filename, fullReadPath, fullWritePath :String; ??????readFileExists, writeFileExists, locked, hasReadPermission, hasWritePermission, hasFolderPermission :Boolean; ??????vMaj, vMin, vMai, vPlat :Integer; BEGIN ??????dateValue := Date(1, 0);??????{ Abbreviated Date, Date Only } ??????GetFile(filename); ??????GetFileInfo(filename, fullReadPath, fullWritePath, ????????????????????????readFileExists, writeFileExists, locked, hasReadPermission, hasWritePermission, hasFolderPermission); ??????GetVersion(vMaj, vMin, vMai, vPlat); ??????AlrtDialog(concat(dateValue, CR, 'Major = ', vMaj, ' Minor = ', vMin, ' Maintenance = ', vMai, ' Platform = ', vPlat)); ??????AlrtDialog(concat(filename, CR, fullReadPath, CR, fullWritePath, CR, readFileExists, ' ', writeFileExists, ' ', locked, ' ', hasReadPermission, ' ', hasWritePermission, ' ', hasFolderPermission)); END; Run(xxx);
  7. It is a bug and I filed it several months ago. I believe it has something to do with the Interactive Settings. I have most of mine toned way down, or off, and I think that is what caused it. Do you have "Selection Highlighting" unchecked in your VW Preferences->Interactive tab? If so, try checking it to see if it comes back. If not, I dunno, it may be another setting. HTH, Raymond
  8. Hi Jack, ???Have you tried GetFileInfo()? It was introduced in v12. From the VSFR: PROCEDURE GetFileInfo (???filename :STRING; ????VAR fullReadPath :STRING; ????VAR fullWritePath :STRING; ????VAR readFileExists :BOOLEAN; ????VAR writeFileExists :BOOLEAN; ????VAR locked :BOOLEAN; ????VAR hasReadPermission :BOOLEAN; ????VAR hasWritePermission :BOOLEAN; ????VAR hasFolderPermission :BOOLEAN ) ; Raymond
  9. I'd like that, too. But, no can do. Raymond
  10. VW only uses one processor except for rendering where it uses all available. Multi-threading (using multiple processors) for them main program is an ongoing wish list item, but it's not going to happen soon, to the best of my knowledge. To make it happen will require a rewrite of just about ... everything. Raymond
  11. Why are spiders allowed to monitor Viewer Profiles? Raymond
  12. Are there duplicate lines in the same position? Deleting the top one "appears" to have no effect. Make sure she is not pressing Option-Select inadvertently. Raymond
  13. Derek, ???In your example you use items 1 & 2. They are reserved for the OK and Cancel buttons. Your radio buttons will need to start at 3 or higher. I'd suggest starting at 11 as it's easy to mentally subtract 10 from you item number to get the button number. ???Charles' way will work perfectly if you don't need to do anything on an item by item basis. But if you need to treat each button separately when pressed and process the events accordingly, then try something like this... case item of ???SetupDialog: begin ??????{ Do setup stuff, initialize variables, controls, text fields, etc. } ??????{ This item only runs once before your dialog is active. } ???end; ???1: begin { Do OK button stuff } end; ???2: begin { Do Cancel button stuff } end; ???11: begin ?????????SetItemEnable(31, False); ? ?????{ Do button 1 stuff } ???end; ???12: begin ?????????SetItemEnable(31, False); ?????????{ Do button 2 stuff } ???end; ???... ???30: begin ?????????SetItemEnable(31, True); ?????????{ Do button 20 stuff } ??????end; ???31: begin ????????? { Do text field stuff, usually nothing until the dialog closes. } ???end; end;??????{ case } Don't worry about memory usage. This is very little overhead in the grand scheme of things. Mostly, you should want your code to be readable when you return to it a year or more from now. The more tricks you play, the worse your memory will be later, unless you are very good at documenting what you do. But if you really want to be frugal, you can do it this way, testing it before the CASE statement... procedure MyDialogDriver(var item: Longint; data :Longint); Begin ???SetItemEnable(31, ItemSel(30));??????{ this tests it on every dialog event } ???case item of ?????? SetupDialog: begin ?????????{ Do setup stuff, initialize variables, controls, text fields, etc. } ?????????{ This item only runs once before your dialog is active. } ?????????{ You'll need to enable Item 31 accordingly for dialog startup. } ??????end; ??????1: begin { Do OK button stuff } end; ??????2: begin { Do Cancel button stuff } end; ??????11: begin { Do button 1 stuff } end; ??????12: begin { Do button 2 stuff } end; ??????... ??????30: begin ????????????SetItemEnable(31, True); { this turns it on } ????????????{ Do button 20 stuff } ??????end; ??????31: begin ????????????{ Do text field stuff, usually nothing until the dialog closes. } ??????end; ???end;??????{ case } End;??????{ MyDialogDriver } ???These are not the only ways to structure your code, just two blunt force approaches. You could also use two case statements with the basic approach Charles suggests, but I digress. HTH, Raymond
  14. Ciao Paolo, ???I noticed you are scaling your temp_Line from SegPt1 (begPt). If you don't draw the line correctly it will scale away from your polyline. Try scaling from the center point of the line. You also might need a bigger scale factor, 20x or 100x, to make sure your line and poly cross. ???GetSegPt1(tmpLineH, begPt.x, begPt.y); ???GetSegPt2(tmpLineH, endPt.x, endPt.y); ???P := (BegPt + EndPt) / 2;??????{ save midpoint of temp_Line in temp_point P } ???HScale2D(tmpLineH, P.x, P.y, 10, 10, false); ???GetSegPt1(tmpLineH, begPt.x, begPt.y);?????{ get new begPt } ???GetSegPt2(tmpLineH, endPt.x, endPt.y);?????{ get new endPt } You could also use procedure LineLineIntersection in a loop with each segment of the poly if you want to catch all intersections. Use the "intOnLines" boolean value that is returned by the procedure to test for an intersection. HTH, Raymond
  15. Hi Geoff, ???Rather than replace duplicate 3DLoci, place your symbol at the same location instead. You will need to loop through each 3DLocus and use its XYZ for the symbol placement with Symbol('sym name', X, Y, 0);. Symbols place in X&Y then use a Move3D(0, 0, Z); to raise it up. You'll want to be in TOP view for it to work correctly. If you want the record information to stay attached you'd have to copy the record from the original locus to the symbol just after you place the symbol. ???The smallest code can be achieved by using ForEachObjectInLayer() but you may find it easier to use a WHILE loop to step through the handles of the 3DLoci if you are new to VS. ???Also, did you search the archives for a script? This question has been asked before and I'd be surprised if there isn't something out there. Raymond
  16. I still use a G4 / 0.5 GHz Dual processor machine and 2008 runs perfectly on it. You should have no problems, unless you have a lot of rendering to do. 2D and 3D drafting works fine. Your limiting factor will be file size, not CPU. Raymond
  17. Yes, when you are done with an object, the handle (variable) can be reused. Many of my scripts have only one handle variable and I access every object on a layer with it, using FOR or WHILE loops. Raymond
  18. J, What you want is somewhat easy to do, especially changing the class attributes. Using the ForEachObject commands is a little tricky, but with a few examples, it's not all that hard. Remember to run this script on a COPY of your work. Going backwards in not as easy unless you don't use Class Attributes at all in your files. Here's a quick and dirty script that makes the changes you outlined (I think) .... PROCEDURE Homogenize; VAR ???I :Integer; ???ClassName :String; ???function SetByClass(H :Handle) :Boolean; ???{ Set Fill Pattern, Pen Color, Line Style & Line Weight to be "ByClass". } ???Begin ??????SetFPatByClass(H); ??????SetPenColorByClass(H); ??????SetLSByClass(H); ??????SetLWByClass(H); ???End; { SetByClass } BEGIN ???{ Change Attributes of all Classes to affect Fill Pattern, Line Style, Pen Color, and Line Weight. } ???for I := 1 to ClassNum do begin ??????ClassName := ClassList(I); ??????SetClFPat(ClassName, 0); { No Fill } ??????SetClLS(ClassName, 2); { Solid Foreground Pen } ??????SetClPenFore(ClassName, 52428, 52428, 65535); { Pen Color = RGB(255) x 257 } ??????SetClLW(ClassName, 6); { Line Weight in mils } ???end;??????{ for } ???{ if you need to change all objects to accept "Attributes By Class", then do the following... } ???ForEachObjectInLayer(SetByClass, 0, 2, 1); { all objects on all layers, active layer=0, 2, 0 } ???ForEachObjectInList(SetByClass, 0, 2, FSymDef); { all objects within symbol definitions } ???SysBeep; { sound when done } END; Run(Homogenize); HTH, Raymond
  19. Jonathan, Add a wish for Floor and Ceiling functions. Floor is a round down function and Ceiling is a round up function, both found in most popular spreadsheets. VW surely needs more functions for its WS. Raymond
  20. Jakes, Welcome. There is a directory in your User folder :User:Your Acct Name:Library:Application Support:Vectorworks:20xx: where xx = 08, 09, etc. that has all your custom stuff in it. If you modify a workspace, it is stored here in the Workspaces folder. Copy your customized workspace from here to the same place on your other machine. Raymond
  21. This problem is one that has been bug-listed and wish-listed. SetOrigin() and SetOriginAbsolute() work in both Palette Scripts and Menu Commands (Plug-ins) while the script is running, BUT, when Menu Commands quit, VW resets the user origin back to where it thinks it was so your changes are not permanent. VW gets it wrong when the Plan is rotated from a script and the User Origin gets reset to a different place (also bug-listed). Bottom line, run scripts that are intended to move the User Origin from a Script Palette, or from the "Run VectorScript" menu (as you've already figured out) and it will work as you desire. Raymond
  22. You might also try using: SetObjBeginningMarker() / SetObjEndMarker() to see how they work. You'll need a handle to the object, though.
  23. From the VS Func Ref: ???Special Notes: ???Marker is obsolete as of VectorWorks13.0 (2008) But, as long as the code still works try Option 0: ???Marker(0, 0.125, 15); which will give you a filled arrow. If fill color is not right, try setting it with FillFore or FillBack, OR, SetFillFore / SetFillBack. HTH, Raymond
  24. Timbo, ???If you want a script to be both stand-alone and callable from a larger script you will need a library (folder) of script parts that you can assemble with $INCLUDE statements in other files. For example: ???PROCEDURE SetLW6; ???PROCEDURE SetFillBlue: ???PROCEDURE SetOutline; ???PROCEDURE SelectAllRects; might be routines you want to call individually or from another script. In your library, split the small routines into two pieces; one that has the procedure definition in one file; and the other that has two lines, an $INCLUDE and a RUN(); File "SetLW6.px": ???PROCEDURE SetLW6; ???BEGIN ??????PenSize(6); ???END; File "RunSetLW6": ???{$INCLUDE \YourLibrary\SetLW6.px } ???Run(SetLW6); ???File "RunSetLW6" is the file you would use to make a Menu Command PIO for the stand-alone execution of "SetLW6". ???In a larger script you can access the procedures in your library by adding several $INCLUDE files then calling the included procedures. File BIG_SCRIPT_1: ???PROCEDURE BIG_SCRIPT_1; ??????{$INCLUDE \YourLibrary\SetLW6.px } ??????{$INCLUDE \YourLibrary\SetFillBlue.px } ??????{$INCLUDE \YourLibrary\SelectAllRects.px } ???BEGIN ??????{ Your code here } ??????SetLW6; ??????SetFillBlue; ??????{ Draw something here } ??????DSelectAll; ??????SelectAllRects; ??????{ More of your code here } ???END; ???Run(BIG_SCRIPT_1); ???If you want to call BIG_SCRIPT_1 from other scripts, then split it in two pieces as shown above. With this setup, you can make changes to any of your files and they will be reflected in all procedures that use them. ???One last caveat, always have at least one blank line at the end of each $INCLUDE file. Without it you will get compiler errors. HTH, Raymond
×
×
  • Create New...