Jump to content

Hello Community!

This Saturday, April 11, from 9am – 1pm EDT we will be performing maintenance on the Vectorworks Community Board. During this time, the site will be unavailable.

Sam Jones

Resource Folder inside Resource Folder

Recommended Posts

Using VS can I create a resource folder inside another resource folder.  Can I move a folder into another folder.  SetParent() does not seem to work.

 

Share this post


Link to post

I would think SetParent() should work. You can also try InsertSymbolInFolder()

Share this post


Link to post

How are you getting the Handle to your created resource folder? Are you sure the Handle you are passing to SetParent() is correct.

 

Share this post


Link to post

The script below fails when the parent exists and when the parent cable does not exist.  It also fails using InsertSymbolInFolder().  Putting a BeginFolder inside a BeginFolder also fails.

 

PROCEDURE PutFolderInFolder;
VAR
    FolderName : STRING;
    FolderHdl : HANDLE;
    Folder2Hdl : HANDLE;
    ok : BOOLEAN;
    
BEGIN
    FolderHdl := GetObject('AP Cable Folder');
    IF FolderHdl = NIL THEN
        BEGIN
            NameObject('AP Cable Folder');
            BeginFolder;
            EndFolder;
            FolderHdl := LNewObj;
        END;
    NameObject('Inside AP Cable Folder');
    BeginFolder;
    EndFolder;
    Folder2Hdl := GetObject('Inside AP Cable Folder');
    ok := SetParent(Folder2Hdl, FolderHdl);
    IF (NOT ok) THEN
        AlrtDialog('ok set parent is false');
    {InsertSymbolInFolder(FolderHdl, Folder2Hdl);}

END;
RUN(PutFolderInFolder);
 

Share this post


Link to post

SetParent() does work for placing resources in folders, but as you observe it fails for symbols. I suspect this is due to somewhat simplistic error checking; you can't place a record in a symbol folder, only a record folder, etc. I'm guessing you are restricted from placing a folder in a folder via script. 

I would file this as a bug, and if it's WAD have it moved to an enhancement request.

Share this post


Link to post

I would expect nested BeginFolders to fail. The first folder would not yet exist when the nested one was trying to be created. 

 

LNewObj only works (as far as I know) on SOME objects that are actually visible in the drawing. I would not expect it to work on resources.

 

Check out CreateFolderN in the function reference.

 

Quote

PROCEDURE PutFolderInFolder;
VAR
    FolderName : STRING;
    FolderHdl : HANDLE;
    Folder2Hdl : HANDLE;
    ok : BOOLEAN;
    
BEGIN
    FolderHdl := GetObject('AP Cable Folder');

    IF FolderHdl = NIL THEN
        BEGIN
            NameObject('AP Cable Folder');
            BeginFolderN(16);
                NameObject('Inside AP Cable Folder');
                BeginFolderN(16);
                EndFolder;
            EndFolder;
        End;

        AlrtDialog(Concat(FolderHdl,'  ',Folder2Hdl));
    ok := SetParent(Folder2Hdl, FolderHdl);
    IF (NOT ok) THEN
        AlrtDialog('ok set parent is false');
    {InsertSymbolInFolder(FolderHdl, Folder2Hdl);}
END;
RUN(PutFolderInFolder);

 

Share this post


Link to post

CreateFolderN creates symbol folders in the operating system not in the Resource Manager.

Share this post


Link to post

Did you run the modification to the sample code I posted? I got folders in the Resource manager.

Share this post


Link to post

It was in the quote in my post above. I had my window set to narrow and could not see the Code block icon and assumed that they had updated the forum and removed it.  Reposted here. This is a minor modification to your code that puts nested folders in for me.  

 

The 16 in the BeginFolderN specifies Symbol folders, but I think you can use most of the type codes for Definitions in the VS Appendix Object Type table that are listed as Definition.

PROCEDURE PutFolderInFolder;
VAR
    FolderName : STRING;
    FolderHdl : HANDLE;
    Folder2Hdl : HANDLE;
    ok : BOOLEAN;
    
BEGIN
    FolderHdl := GetObject('AP Cable Folder');
    IF FolderHdl = NIL THEN
        BEGIN
            NameObject('AP Cable Folder');
            BeginFolderN(16);
                NameObject('Inside AP Cable Folder');
                BeginFolderN(16);
                EndFolder;
            EndFolder;
        End;
        AlrtDialog(Concat(FolderHdl,'  ',Folder2Hdl));
    ok := SetParent(Folder2Hdl, FolderHdl);
    IF (NOT ok) THEN
        AlrtDialog('ok set parent is false');
    {InsertSymbolInFolder(FolderHdl, Folder2Hdl);}
END;
RUN(PutFolderInFolder);

Share this post


Link to post

Success !!  I did not understand the explanation of the BeginFolderN() command.  I do now.

 

Thanks.

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