Assembly Posted February 5, 2011 Share Posted February 5, 2011 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. Quote Link to comment
Assembly Posted February 6, 2011 Author Share Posted February 6, 2011 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); Quote Link to comment
islandmon Posted February 6, 2011 Share Posted February 6, 2011 Have you tried using a worksheet : Type=Symbol and then export the data to a FilePath. Quote Link to comment
JBenghiat Posted February 6, 2011 Share Posted February 6, 2011 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 Quote Link to comment
Assembly Posted February 7, 2011 Author Share Posted February 7, 2011 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; Quote Link to comment
JBenghiat Posted February 7, 2011 Share Posted February 7, 2011 Actually, just use ImportResourceToCurrentFile to bring in the symbol using your resource list and you can avoid knowing the file. It's made to work with BuildResourceList. You can also go the workaround way and have a new subfolder for every resource file. http://developer.vectorworks.net/index.php?title=VS:ImportResourceToCurrentFile -Josh Quote Link to comment
Assembly Posted February 7, 2011 Author Share Posted February 7, 2011 wow- easy. Quote Link to comment
Recommended Posts
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.