Jump to content
Developer Wiki and Function Reference Links Read more... ×
Sign in to follow this  
Assembly

Build a Symbol list from another file.

Recommended Posts

Anyone know how to build a list of symbols from another file?.

I've looked at

kSymDef:=16;

kRepetMasonary:=127;

BuildResourceList(kSymDef,kRepetMasonary,'',ListCount):

This builds a list of masonary repeat symbols.

I want to be able to create my own file in the user folder which I can access to build a symbol def list from.

Share this post


Link to post

A couple functions that build image selector dialogs...

Still can't see how to get access to symbols in my own file.

PROCEDURE Tryit;

FUNCTION ImageSelectSymbolFolder(FolderName:STRING):HANDLE;

VAR

dialog1 :INTEGER;

int :INTEGER;

str :STRING;

iCount: INTEGER;

hTemp: HANDLE;

SelectINT:INTEGER;

SymString:STRING;

PROCEDURE dialog1_Handler(VAR item :LONGINT; data :LONGINT);

BEGIN

CASE item OF

SetupDialogC:

BEGIN

str := GetSDName(FSymDef);

int := InsertImagePopupObjectItem(dialog1, 4, str);

iCount:=0;

hTemp:=FInFolder(GetObject(FolderName));

While hTemp<> NIL Do

BEGIN;

iCount:=iCount+1;

int:=InsertImagePopupObjectItem(dialog1, 4, GetSDName(hTemp));

hTemp:=NextSymDef(hTemp);

END;

END;

END;

SelectINT:=GetImagePopupSelectedItem(dialog1,4);

SymString:=GetImagePopupObject(dialog1,4,SelectINT);

END;

BEGIN

dialog1 := CreateLayout(Concat('Select From: ',FolderName), FALSE, 'OK', '');

CreateControl(dialog1, 4, 10, '', 0);

SetFirstLayoutItem(dialog1, 4);

int := RunLayoutDialog(dialog1, dialog1_Handler);

ImageSelectSymbolFolder:=GetObject(SymString);

END;

FUNCTION ImageSelectResourceFile(FolderID:INTEGER):HANDLE;

VAR

dialog1 :INTEGER;

int :INTEGER;

str :STRING;

iCount: INTEGER;

SymDefCount:INTEGER;

hTemp: HANDLE;

SelectINT:INTEGER;

SymString:STRING;

ListID:LONGINT;

PROCEDURE dialog1_Handler(VAR item :LONGINT; data :LONGINT);

BEGIN

CASE item OF

SetupDialogC:

BEGIN

str := GetSDName(FSymDef);

int := InsertImagePopupObjectItem(dialog1, 4, str);

ListID := BuildResourceList(16, FolderId, '', SymDefCount);

FOR iCount := 1 TO SymDefCount DO

BEGIN

int := InsertImagePopupResource(dialog1, 4, ListID, iCount);

END;

END;

END;

SelectINT:=GetImagePopupSelectedItem(dialog1,4);

SymString:=GetImagePopupObject(dialog1,4,SelectINT);

END;

BEGIN

dialog1 := CreateLayout(Concat('Select From'), FALSE, 'OK', '');

CreateControl(dialog1, 4, 10, '', 0);

SetFirstLayoutItem(dialog1, 4);

int := RunLayoutDialog(dialog1, dialog1_Handler);

ImageSelectResourceFile:=GetObject(SymString);

END;

BEGIN;

Message(ImageSelectResourceFile(125));

END;

RUN(Tryit);

Share this post


Link to post

Have you tried using a worksheet : Type=Symbol

and then export the data to a FilePath.

Share this post


Link to post

To get BuildResourceList to see your own files, you need to place the file in one of the folders VW can find, preferably un your VW user folder. User App Data, Libraries, Plug-ins, Plug-In Data are all good options for whose constants to pass.

In that folder, create your own folder to contain your own file of symbols. Build resource list will list resources for all documents in a folder and not a specific file. The intent, I think, is that you can just add your own file to, say, the masonry repeat symbols folder, and you would see both the default content and your content. I believe in the current VW version, resources are grabbed from both your user folder and the app folder, but this has been the source of some confusion.

So, for example, if your symbols are in {User app data}/plug-ins/my plugins/masonry symbols, pass -2 as your folder constant and 'my plugins\masonry symbols' as the subfolder name.

-Josh

Share this post


Link to post

Thanks Joshua.

That does it. I modified the function below.

I can now create my own folder of resource files to store symbols I want to access. BUT (there always is a but with VS) BuildResourceList does not keep track of the file from which the list is built from. If you have two files located in the resource folder it will load the symbols of both folders. The function returns a handle to the Symbol, BUT as the symbol is not yet in the file it can't be used.

I need to use CopySymbol to import the symbol to the current file. To use copy symbol I have to know the path to the file which the symbol is in. urgh.

FUNCTION ImageSelectResourceFile(FolderID:String):HANDLE;

VAR

dialog1 :INTEGER;

int :INTEGER;

str :STRING;

iCount: INTEGER;

SymDefCount:INTEGER;

hTemp: HANDLE;

SelectINT:INTEGER;

SymString:STRING;

ListID:LONGINT;

PROCEDURE dialog1_Handler(VAR item :LONGINT; data :LONGINT);

BEGIN

CASE item OF

SetupDialogC:

BEGIN

str := GetSDName(FSymDef);

int := InsertImagePopupObjectItem(dialog1, 4, str);

ListID := BuildResourceList(16, -14, Concat('Assembly:',FolderID), SymDefCount);

FOR iCount := 1 TO SymDefCount DO

BEGIN

int := InsertImagePopupResource(dialog1, 4, ListID, iCount);

END;

END;

END;

SelectINT:=GetImagePopupSelectedItem(dialog1,4);

SymString:=GetImagePopupObject(dialog1,4,SelectINT);

END;

BEGIN

dialog1 := CreateLayout(Concat('Select From'), FALSE, 'OK', '');

CreateControl(dialog1, 4, 10, '', 0);

SetFirstLayoutItem(dialog1, 4);

int := RunLayoutDialog(dialog1, dialog1_Handler);

ImageSelectResourceFile:=GetObject(SymString);

END;

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

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.

×