Jump to content

MullinRJ

Member
  • Posts

    2,007
  • Joined

  • Last visited

Posts posted by MullinRJ

  1. 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

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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

  9. 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

  10. 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

  11. 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

  12. Carl,

    515 vertices is workable, compared to 16K vertices. It's still high, but you're in the right ballpark. Is there any reason you are converting to Polygons? Polylines will extrude.

    The built in Poly Smoothing functions in VW are inadequate for this task. There are some 3rd party tools. The one that comes to mind is a VectorBits tool - Purge Polygons. Vector Bits - Donationware There are probably others, but you'll have to search the web.

    HTH,

    Raymond

  13. Hi Carl,

    ???The vertex count is WAY too high in the letters to be useful for any extrusion. The capital S alone has 16589 vertices. You will need to reduce the vertex count by 10X to 100X if you want VW to handle these as extrudes with any alacrity.

    Raymond

  14. Timbo,

    ???Since no one else has posted I decided to try this. hMoveBackward() does work. Here's an example that creates a new layer with a stock name, numbers it and sends it to the bottom. It can be easily made into a procedure or function that can be called from within a larger script.

    Raymond

    PROCEDURE NewLayerOnBottom;
    { Create a new layer and send it to the bottom of the stacking order. }
    CONST
    BLN = 'Layer';		{ Base Layer Name }
    VAR
    I :Integer;
    S :String;
    BEGIN
    I := 1;
    while (GetLayerByName(concat(BLN, ' ', I)) <> nil) do 
    	I := I + 1;
    S := concat(BLN, ' ', I);
    Layer(S);
    hMoveBackward(GetLayerByName(S), True);	
    END;
    Run(NewLayerOnBottom);

    • Like 1
×
×
  • Create New...