Jump to content

Attach record to symbol in resource manager


Recommended Posts

hey y'all,

 

i need to go though a bunch of symbols and attach a record and fill out the fields and I'm trying to automate that...  ive got a way to do it for symbols i have inserted into a drawing but i need to find a way to do it to the symbols that live in the resource browser. 

 

is there a way to attach or update a record for a symbol in the resource browser? 

 

EDIT:

i kinda shifted directions half way though this... this topic is really about how to return all the lighting devices in the resource browser.

Edited by Jayme McColgan
Link to comment

You can attach a record to all the symbols in a selected RM folder via the tools menu.

 

This will just apply the default record field data to the symbols. If you want to change the record info for these symbols from the default you need to right click on a symbol in the rm and select “attach record”.

 

Select the record and click on the edit fields button.

Link to comment
5 hours ago, Boh said:

You can attach a record to all the symbols in a selected RM folder via the tools menu.

 

This will just apply the default record field data to the symbols. If you want to change the record info for these symbols from the default you need to right click on a symbol in the rm and select “attach record”.

 

Select the record and click on the edit fields button.

yeah... but how do i do that from a python script. 

Link to comment
26 minutes ago, Jayme McColgan said:

can't really seem to figure out how to do that for the items that live in the resource browser. I'm not trying to work on symbols that are placed in my drawing...

 

Which items? Different items reside in different lists. The SymbolDefs are in their own list. The Resource Manager presents items from multiple lists, making it look like they are all under one roof, but they are not.

 

Raymond

Link to comment

yeah i got that. ideally i want to go though everything in the resource browser. 

 

I'm starting to make some head room with vs.FSymDef() and others that go along with it. i understand i will have to deal with each type of symdef and loop though folders within folders as they pop up to get symbols within.

 

ill pick this back up tomorrow. going to sleep

 

Link to comment
1 hour ago, Jayme McColgan said:

so heres a slightly different question... 

how do i loop through all symbols in the resource browser and build a list if a symbol has a certain record attached to it.

in this case i need to build a choice list for a dropdown in a dialog box.= based off symbols that have a specific record attached to it.

 

 

   Here's a very useful script you'll have a hard time ferreting out of the Script Documentation. Sorry, it's in Pascal, so you'll have to Pythonize it. Like you, it's bed time. I assume you can build your list from this. Good luck, good night.

 

PROCEDURE xxx;
{ Show the name of each symbol definition that has the record name 'Bob' attached to it. }
CONST
	RecName = 'Bob';

	function DoIt2It(H :Handle) :Boolean;
	Begin
		if (Eval(H, (R IN [RecName])) = 1) then
			AlrtDialog(GetName(H));		{ show Symbol Name }
	End;		{ DoIt2It }

BEGIN
	ForEachObjectInList(DoIt2It, 0, 0, FSymDef);
END;
Run(xxx);

 

Raymond

Link to comment

here my version, might be able to be cleaned up some but it works for me. 

 

import vs

### init List of all lights
all_lights = []

### init List of lights to ignore
cur_lights = ["Viper", "Leko Body", "ETC Source 4 Body"]

### 121 = Lighting Devices
### 92 = Symbol Folders

### Loop though everything in a current symbol folder
def start1(cur_handle):
    first_sym = vs.FInSymDef(cur_handle)
    for i in range(20):
        if first_sym.type == 16:
            add_Symbol(first_sym)
        first_sym = vs.NextSymDef(first_sym)

### Add lighting device to list
def add_Symbol(current):
    hasRecord = vs.Eval(current,("R IN ['Light Info Record']"))
    if hasRecord:
        if vs.GetName(current) not in cur_lights:
            all_lights.append(vs.GetName(current))
            cur_lights.append(vs.GetName(current))

    return None

### main loop
def start():
    #path = vs.GetFolderPath(23) + "MIG Symbols.vwx"
    #symfold_list, num_list = vs.BuildResourceListN(92, path)
    symfold_list, num_list = vs.BuildResourceList(92, 0, "")
    vs.AlrtDialog(str(num_list))

    for i in range(num_list):
        cur_handle = vs.GetResourceFromList(symfold_list, i)
        start1(cur_handle)

    vs.AlrtDialog(str(all_lights))
    return None

 

Link to comment

a few issues things i encountered... i encountered these in both VW2020 and VW2022

 

- i think vs.BuildResourceList() is broken... the code below (which is just a portion of the whole script) return the correct num_list but the symfold_list wouldn't have a handles in it. i could also be using it wrong...

path = vs.GetFolderPath(23) + "MIG Symbols.vwx"
symfold_list, num_list = vs.BuildResourceListN(92, path)

 

- i tried building a list using type 121 (Lighting Instrument - Symbols) but it always returned nothing.

Edited by Jayme McColgan
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...