Jump to content
Wizard12

Create a List of Symbols in Resources

Recommended Posts

Hi, I was wondering if anyone has come across a script that will Build a Resource List of the Symbol types in a document.  I have tried to find examples to understand how to setup an array but have not been successful.  I need this list do a comparison WHILE a symbol is being generated to see if the name already exists, once it does exist it will place the existing symbol instead of executing a creation procedure.  Any scripting help would be appreciated.

 

TIA,

Eric

Share this post


Link to post

Untested, but something like this should work...

 

Procedure CheckSymbolExists;

VAR

    gsSymNameCurrent : STRING;

 

Function DoIt(h1 : HANDLE) : BOOLEAN;
VAR
    sSymNameExist : STRING;
BEGIN
    IF (h1 <> Nil) & (GetType(h1) = 16) THEN BEGIN
        sSymNameExist := GetSDName(h1);
        IF sSymNameExist = gsSymNameCurrent THEN SysBeep;
    END;
END;

 

BEGIN

    gsSymNameCurrent := StrDialog('Symbol name to search for:', '');
    ForEachObjectInList(DoIt, 0, 2, FSymDef);
END;
Run(CheckSymbolExists);

  • Like 1

Share this post


Link to post

Also untested, but something like this should get you a Resource List.

 

Procedure MakeRL;

 

var

  H1: Handle;

  List1: LongInt;

  NumItems: LongInt;

 

Begin

  List1:=BuildResourceList(16, 0, '', NumItems);

End;

 

Run(MakeRL);

 

To find if a specific symbol exists you would need to loop through the list. Using the same variables as above (both parts will need to be part of your overall script), it might be something like:

 

var.  L1: LongInt;

        S1: String;

       Exists: Boolean;

 

Exists:=False;

For L1:= 1 to NumItems

  Do

     Begin

        S1:=GetNameFromResourceList(List1, L1);

        If S1='My Symbol Name' then Exists:=True;

    End;

 

Remember that the resource list will give you all the symbol definitions in the file, not just symbols that are actually inserted in the document.

 

  

  • Like 1

Share this post


Link to post

@Wizard12 ,

   This may be overly simplistic, but you can check the existence of a name without building a list with:

 

NameExists := GetObject('Your test name here') <> nil;

 

or if you want to also test if it is a Symbol, then:

 

H := GetObject('Your test name here');
if (H <> nil) then begin
    if (GetTypeN(H) = 16) then begin
        { name exists and it's a Symbol }
    end
    else begin

            { name exists and it's NOT a Symbol }

    end
end
else begin

    { Name does not exist }
end;

 

HTH,

Raymond

  • Like 2

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