Jump to content

Don't Delete Resource in Use


twk

Recommended Posts

Is there any way/function via scripting to tell vectorworks to delete a resource eg class, if its not being used? Sort of like the purge command. But through scripting. Had a look at the DeleteResource but it doesnt tell you anything about how to deal with resources that are in use.

Any thoughts VS/SDK experts?

Cheers

Tui

Link to comment

I think the easiest way is to use criteria and the count function to find out if a class is being used.

If that doesn't do it, traversing all the objects manually with one of the available functions yes.

But it might get tricky for symbol definitions not used in the drawing. You could traverse each definition and search it's contents as well.

Any way, it's important you do a deep search, including group contents and make the search recursive.

http://www.vectorworks.net/support/custom/vscript/example

Shows some recursive functions.

Edited by Hippocode
Link to comment

Am wanting to use the symbol display call in a dialog.

def vs.CreateSymbolDisplayControl(dialogID, itemID, symbolName, height, width, margin, renderMode, view):
return None

But it appears I cant browse/create a list(using BuildList) of symbols from an external file to be used in this function.

So what I've done was, imported all the symbols into the file, so I can see them in the dialog through the SymbolDisplayControl, and once I've exited the dialog, purge all the symbols/classes/etc imported that are not in use.

The idea is to browse a files symbol resources, and have a search text box to search through the file, while showing the symbol in dialog.

Bascically what I'm wanting is:

- Load Ext File

- Be able to search the symbol list of that file

- Display this symbol in the SymbolDisplayControl

- If its selected in the ListBox, import this symbol.

After importing that symbol, Im needing to delete every symbol thats not selected. Seeing that I imported everything, I need a way to filter out everything except the symbol selected.

Will PM code if anyone wants to take a stab at it.

Edited by twk
Link to comment

That scenario makes the problem a bit easier to solve, as you know what symbols are being imported. Here are the steps, in non code terms:

Assuming you already have the document's symbols loaded

Get the external resource list

Step through the list, and import symbols that aren't already in the document. Create a new list of the handles you are importing.

After the user selects a symbol, remove that symbol from the imported resource list. Then delete the resources in the list from the current file.

Note that the resource list functions pre-date Python. Some of what they do can be accomplished with a regular list of handles.

-Josh

Link to comment

Ah ok.

What does deleting resource list actually do? Does it delete the actual object(eg symbol) from the file? Including all classes/textures associated with objects in that symbol as well?

Curious as to what Resource Lists actually are? Could you do the same with Python lists? Or are they totally different?

Link to comment
Ah ok.

What does deleting resource list actually do? Does it delete the actual object(eg symbol) from the file? Including all classes/textures associated with objects in that symbol as well?

No a list is just a list of some sort of handle to the object. Adding or removing items from the list has nothing to do with adding or removing a resource.

See it as a list of symbol names, removing a name (string) from a list doesn't delete the symbol.

In your case that's great as you know which symbols to delete without having to do a search.

FYI, if you use a thumbnail control, the symbols don't need to be imported for them to show up.

Have a look at my SelectSymbolDialog which is also available as a custom VS function.

Edited by Hippocode
Link to comment

Will it not be easier to use a ThumbnailPopup? This in combination with a resource list will do what you are asking, without the need to import symbols, this will be so much easier.

Something like this:

1. You can build a resource list with resources from other documents, so you'll have access to them without needing to import them.

2. You can use a resource list to fill up the thumbnail popup, and VW will show them with the preview, like you can see them in the resource browser.

3. You can then add your own filtering, by refilling the popup after the filter has changed.

Link to comment

Thanks Hippocode and Dieter for replying.

It would be easier to use a popup, which is what I've been using until I found out about the SymbolDisplayControl function.

The reason I'm trying to get SymbolDisplayControl to work is because it has a bigger preview window.

This exercise is to enable our users to browse our Architectural Details from an external file/files. By text search and visual display.

Edited by twk
Link to comment
Thanks Hippocode and Dieter for replying.

It would be easier to use a popup, which is what I've been using until I found out about the SymbolDisplayControl function.

The reason I'm trying to get SymbolDisplayControl to work is because it has a bigger preview window.

This exercise is to enable our users to browse our Architectural Details from an external file/files. By text search and visual display.

If you stay into the importing symbols option, be aware of what has to be done with duplicates. What if the user has imported one of these symbols before, kept the name but modified it ? Will you just overwrite it ?

Link to comment
Thanks Hippocode and Dieter for replying.

It would be easier to use a popup, which is what I've been using until I found out about the SymbolDisplayControl function.

The reason I'm trying to get SymbolDisplayControl to work is because it has a bigger preview window.

This exercise is to enable our users to browse our Architectural Details from an external file/files. By text search and visual display.

One way to avoid the bigger display is to choose names that really says what it is, so they can see from the smaller preview what they want. I know it's not the same, but sometimes you better don't go to far just for a small usability improvement when you don't have full control of the main program.

Link to comment
If you stay into the importing symbols option, be aware of what has to be done with duplicates. What if the user has imported one of these symbols before, kept the name but modified it ? Will you just overwrite it ?

When you're stepping through the resource list from an external file, GetResourceFromList will return a handle if it matches a resource in the current file and nil if the resource doesn't exist. This lets you only import non-matching resources and flag any imported resources for possible deletion.

-Josh

Link to comment
  • 2 months later...

Hi Guys, apologies for overlooking this thread, totally missed it!

Your thoughts are much appreciated.

If you stay into the importing symbols option, be aware of what has to be done with duplicates. What if the user has imported one of these symbols before, kept the name but modified it ? Will you just overwrite it ?

--Thinking to use a list of handles instead.

One way to avoid the bigger display is to choose names that really says what it is, so they can see from the smaller preview what they want. I know it's not the same, but sometimes you better don't go to far just for a small usability improvement when you don't have full control of the main program.

--That is an alternative

When you're stepping through the resource list from an external file, GetResourceFromList will return a handle if it matches a resource in the current file and nil if the resource doesn't exist. This lets you only import non-matching resources and flag any imported resources for possible deletion.

-Josh

--Thats sound insight Josh, thanks.

It seems like this little side project will be abandoned seeing the upcoming new Resource Browser for 2017 (Hopefully). I wonder if they got the idea from someone? ;)

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