Jump to content
Ion

Problems creating & naming linestyles

Recommended Posts

I created a script that allows users to set the default linestyle, lineweight, & color to our office standard dash, or change existing selected items to other office standards. I also decided to use the script to make sure that the document has the standard line styles.

 

I will include the script below, it works in that it creates the linestyles, but the index the creation returns is not the actual index of the line. i.e. GetDashStyleIndex() would return -1 for the first execution, but if I then ran a check using name2Index() it would return 7. Therefore the naming function would not work. 

 

My workaround was to have the standard line types in a default content folder in the User folder, the creation would associate the name to the line definition.

 

Not sure if I am missing something obvious.

 

Thanks,

 

Ion

 

Procedure dashTool;
CONST
    kLW = 1;
VAR 
    result                      :BOOLEAN;
    intResult,switch    :INTEGER;
    dashIndex              :LONGINT;

 

Function SetLine(objH : HANDLE):BOOLEAN;
BEGIN
    {Set selected object's fore and back pen colors and lineweight}
    SetLW(objH, kLW);
    SetPenFore(objH,34952,34952,34952); {grey}
    SetPenBack(objH, 65535,65535,65535); {white}

    {Using intResult, call the dialog for the first iteration of ForEachObjectOnLayer()}
    IF (intResult = 0) THEN BEGIN
        switch := AlertQuestion('Select Dash Type to Continue', '', 1, 'Standard', 'Centerline', 'Property Line', 'Tight Dash');
        intResult := 1; {setting intResult to non-zero values prevents multiple calls of the dialog}
    END;

    {based on which button is pressed, set all selected objects to a given linestyle (except property which modifies
        Line color and weight}
    CASE switch OF
        0:    SetLSN(objH,-Name2Index('pults centerline'));

        1:    SetLSN(objH,-Name2Index('pults standard dash'));

        2:    BEGIN
                SetPenFore(objH,6168,8738,52685); {blue}
                SetPenBack(objH, 65535,65535,65535); {white}
                SetLW(objH, 12);
                SetLSN(objH,-Name2Index('pults property line'));
            END;

        3:    SetLSN(objH,-Name2Index('pults tight dash'));


    OTHERWISE Message('Unknown Error');

   END;
    
    {Ensure that the object shows the result of the linestyle change without user interaction}
    ResetObject(objH);
END; 


BEGIN 

    intResult := 0; {inititilazation to trigger dialog}
    
    {Create the 5 office dash styles. Create Line style then assign name using the index returned by GetDashStyle()}    


    dashIndex := GetDashStyleIndex(FALSE, 1, 1/8", 1/32"); {pults standard dash}
    result := SetDashStyleName(dashIndex, 'pults standard dash');

 

    dashIndex := GetDashStyleIndex(FALSE, 1, 1/16", 1/32");
    result := SetDashStyleName(dashIndex, 'pults drip line');
    
    dashIndex := GetDashStyleIndex(FALSE, 1, 1/32", 1/32");
    result := SetDashStyleName(dashIndex, 'pults tight dash');
        
    dashIndex := GetDashStyleIndex(FALSE, 2, 1/8", 1/32", 1/64", 1/32");
    result := SetDashStyleName(dashIndex, 'pults centerline');
        
    dashIndex := GetDashStyleIndex(FALSE, 3, 1", 1/32", 1/16", 1/32", 1/16", 1/32");
    result := SetDashStyleName(dashIndex, 'pults property line');
        
    {Set default lineweight to 1 mil, or 0.03mm}
    PenSize(kLW);

 

    {Set default line style to 'pults standard dash'}
    PenPat(-Name2Index('pults standard dash'));    
    
    {Set default fore and back pen colors}
    PenFore(34952,34952,34952); {grey}
    PenBack(65535,65535,65535); {white}

 

    {Set default fore and back fill colors and fill style}
    FillFore(0,0,0);
    FillBack(65535,65535,65535); {white}
    FillPat(0);

 

    {Set default markers to be off}
    result := SetDefaultBeginningMarker(0, 15, 0.125, 0, 0, 2, FALSE);
    result := SetDefaultEndMarker(0, 15, 0.125, 0, 0, 2, FALSE);
    
    {if items are selected on editable layers, send handle to SetLine()}
    ForEachObjectInLayer(SetLine, 2, 0, 4);

END;
Run (dashTool);
 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


 

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