Jump to content
Developer Wiki and Function Reference Links ×

Build a Symbol list from another file.


Assembly

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.

Link to comment

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);

Link to comment

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

Link to comment

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;

Link to comment

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.

×
×
  • Create New...