Notifications
Clear all

[Closed] ATSOps and Selecting Files

hi,
I am scripting some file re-targeting with the help of the ATSOps functions. Generally

ATSOps.Refresh()
ATSOps.ClearSelection()
ATSOps.SelectFiles #(oldFile)
ATSOps.RetargetSelection newFile

works fine, except with some XRefs. Of course I can’t change the paths within the Xref-ed files. But if I have the same asset files within the current max scene and in the Xref-ed files, I can’t change the scene files either with the method above. With ATSOps.SelectFiles #(oldFile) you select all occurrences of the file within the asset tracker and to my knowledge there is no way to select only the file that belongs to the scene and not the Xref file. If you have both files selected, the one belonging to the scene and the one belonging to the Xref, ATSOps.RetargetSelection newFile doesn’t work anymore.

Then my second approach is

ATSOps.ClearSelection()
ATSOps.SelectFiles #(oldFile)
ATSOps.SetPathOnSelection newFile

Which works as the path is set for the scene asset file and for the xref asset file it is ignored (or better at first it is set in the asset tracker but not permanently saved like that) The problem with this is, that max gives an error message (something about “the asset is deleted”). Nonetheless the retageting worked and the message can be ignored but I would need to suppress the error message somehow.

I guess my question is: how to select only the editable file within the asset tracker even if that file is part of a Xref as well?

thanks

9 Replies

Are you talking about nested xrefs and wanting to select/repath the parent (referenced directly in the scene) and not the children (which are referenced inside the the parent xref file)? I don’t have a solution, yet, but knowing the situation better may help with getting something.

Also, what version of 3ds Max? 2010 added some new asset management interfaces outside of the ATSOps.

-Eric

EDIT: A few things to look at would be ATSOps.GetDependentFiles (should be able to collect a list of the dependent files from the parent) and/or ATSOps.RetargetAssets (allows you to retarget based on a Max Object, so you could repath for specific geometry or something like that).

Interface: ATSOps[left]<integer>ATSOps.GetDependentFiles <string>Filename <bool>Recurse <&string array>FileListIncludeOutputFiles:<bool>
[/left]
[left]FileList is In and Out parameter
[/left]
[left]IncludeOutputFiles default value: true
[/left]
[left]Collects the dependent files of the specified filename into the by-reference FileList array.
[/left]
[left]If the Recurse boolean parameter is set to true, also recurses through all collected files, collecting their dependent files too.
[/left]
[left]If the IncludeOutputFiles: optional keyword argument is not specified or specified and set to true, output files will also be included in the dependency list. If it is specified and set to false, output files will not be included.
[/left]
[left]Returns the number of files collected in the FileList array

Interface: ATSOps[left]<bool>ATSOps.RetargetAssets <&maxObject>AssetOwner <filename>OldPath <filename>NewPath CreateOutputFolder:<bool>
[/left]
[left]AssetOwner is In and Out parameter
[/left]
[left]CreateOutputFolder default value: false
[/left]
[left]Retargets the assets of the specified asset owner from the given old path to the new path.
[/left]
[left]AssetOwner – The ReferenceTarget object from which assets are declared
[/left]
[left]OldPath – Used to determine which asset to retarget. Any asset declared with this path will be retargeted to NewPath.
[/left]
[left]NewPath – The retarget value.
[/left]
[left]If the optional CreateOutputFolder: keyword parameter is supplied and is true, the new path will be created if it does not exist.
[/left]
[left]This method calls the EnumAuxFiles implementation of ReferenceTarget to get a listing of assets.
[/left]
[left]Returns true if the action succeeded and at least one assets was repathed, false if no asset was repathed.

[/left]
[/left]

Hi Eric,
no, I don’t want to do anything with the xref files or the files that are included in the xref. Unfortunately some of the xref files happen to include exactly the same, for example, image files as the base max scene. Then I only want to retarget the image file that belongs to the base max file but I have problems to select only that file, not the one belonging to the xref as well.
I know it is a messy description, sorry…but I can’t think of a better way to describe it. And, we are working with max2008 64bit.
thanks

So basically you have something like this:

> Scene
> Maps
FileA.jpg | \SomePath
FileB.jpg | \SomePath
> Xrefs
FileA.max | \SomePath
> Maps
FileA.jpg | \SomePath
FileB.jpg | \SomePath
And you want to repath the top FileA.jpg and FileB.jpg? Do the nested maps have different paths from the scene paths? Do you know where the scene maps may be used (objects, maps, materials, etc)?

-Eric

Eric,
yes that’s the scenario and I do want to repath FileA.jpg and FileB.jpg. The nested maps can have the same path as the ones of the base scene. The maps could be used for anything. The script is similar to max’s asset tracking dialog and it would be better if the script wouldn’t need to care what the files are used for.

thanks

The reason I was asking what it is used for is because you can use the RetargetAssets to retarget specific assets, but you need the maxobject as reference. There is no way that I can see to do what you need, because the select command takes a string array as parameter (which may not be unique) instead of a unique index. Maybe it could be hacked around using UIAccessor. In 2010 there are new methods for working with assets, but that won’t help you in 2008.

-Eric

Eric,
thanks for your help. At least I know now that I am not missing something obvious. I have never warmed up to the UIAccessor functionality. Do you see a promosing approach with that for retargeting a bounch of files within the asset tracker?

Or if I stay with the ATSOps.SetPathOnSelection is there a way to surpress the error message? Or did you mean to use the UIAccessor for that?

Thanks again

My idea with UIAccessor, which I have little to no experience with, would be to make sure only the paths you want changed are selected. So you could automate the selection without manually selecting each entry. The problem is I honestly have no idea if that is possible. I don’t reference materials, so I have never run into the issue you are describing myself.

Sorry I couldn’t be of any more help,
-Eric

ok, what is working for me right now:
(I know it’s ugly and I won’t get into maxscript heaven for it…but you gotta do what you gotta do…)


fn closeErrorDilaog = (
    local wh = dialogMonitorOps.getWindowHandle()
    if (wh != 0) then (
         uiAccessor.pressDefaultButton()
         true
    ) else false
)

dialogMonitorOps.unRegisterNotification id:#fileMan_closeErrorDilaog
dialogMonitorOps.enabled = true
dialogMonitorOps.interactive = false
dialogMonitorOps.registerNotification closeErrorDilaog id:#fileMan_closeErrorDilaog
ATSOps.ClearSelection()
ATSOps.SelectFiles #(oldfile)
ATSOps.SetPathOnSelection newfile
ATSOps.Refresh()
dialogMonitorOps.enabled = false

This just automatically closes the error message that I get for trying to set the path of a xref asset.

Hi,
one more follow up question:
Can you confirm that if a file is actually missing (even though it is not indicated as “missing” in the asset tracker), you can’t select the file anymore with

ATSOps.SelectFiles #(noneExistingFilePath)

Slowly these ATSOps are starting to annoy me…