Notifications
Clear all

[Closed] How to check that XRefScene deleted or not?

Ah, that test is failing to work correctly when there are multiple scene xrefs present… I need to do a test that is specific to MAXSceneXRef values.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it fails for all < 2017 versions for any number of xref scenes… it’s a fundamental problem. the tree of an xref scene has to be stored in the class instance. that’s what i do… but for me it’s a pain to make my replacing class looks as an originally built-in

@Denis. What does this return???

isdeleted myundefinedvariableIJustmadeUp

In 2016 I get…
>>>isdeleted myundefinedvariableIJustmadeUp
– No ““isDeleted”” function for undefined

In 2017 upwards I get…
>>>isdeleted myundefinedvariableIJustmadeUp
false

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it returns what i show in the commented part of the code snipped

((val)->ref_deleted // no. what for? it’s a valid value and not collected yet

( (val)->NumRefs() > 0 && ((val)->GetReference(0) == NULL) ) // sure not … because the scene still exits

TestAFlag(A_IS_DELETED) // see above

( ((val)->GetReference(0)->GetInterface(INODE_INTERFACE)==NULL) // not our case

(((INode*)(val)->GetReference(0))->GetTMController() == NULL) || (((INode*)(val)->GetReference(0))->GetParentNode() == NULL) [b] // not our case as well

[/b]it passes all these conditions just fine to stay valid

it’s what i worry about… MaxSceneXRef is already specific enough

@Larry

i would appreciate to see the code behind check_for_xref_deletion()

Why you do not use xrefs.getXRefFileCount() method ?


fn IsValidXref xref = (
   local isValid = false
   local numXrefs = xrefs.getXRefFileCount()
   for index in 1 to numXrefs where xrefs.getxreffile index == xref do exit with isValid = true
   isValid
)
(
   resetmaxfile #noPrompt
   b = box()
   savemaxfile (file = getdir #temp + @"\xref_test.max")
   resetmaxfile #noPrompt
   xx = xrefs.addnewxreffile file quite:on
   xs = xrefs.getxreffile 1
   format "added... % > % == %
" xx xs (xx == xs)
   delete xs
   format "valid:% deleted:%
" (isvalidobj xs) (isdeleted xs)
   format "isXrefValid %
" ( IsValidXref xs )
)
/* output:
added... XRefScene:"xref_test.max" > XRefScene:"xref_test.max" == true
valid:true deleted:false
isXrefValid false
*/

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

there is no a problem to get that a xref scene is in deleted stage… but it’s like having a key with tag of the room number. but you have only three choices to know if it’s good:
#1 try to open by tag address and break the key if it’s not good anymore
#2 go to the housekeeper and ask to read the tag carefully, ask to check the database, ask to check any claims and possible issues (check by name pattern)
#3 forget about the tag, go and ask all neighbors, if any one will recognize it, that means the key is not yours (search in valid scenes)

i want a simpler way…

Denis T, funny thing we are looking at that now in the SDK…

We have just started but get the Xref Scene


Xref_O_MissingPlugs = GetClassInstances(SYSTEM_CLASS_ID, XREFOBJECT_CLASS_ID);
IXRefObject* xObj = (IXRefObject*)Xref_O_MissingPlugs[i];

MaxSDK::AssetManagement::AssetUser xasset = xObj->GetCurFile();
MSTR firstPath = xasset.GetFileName();

you are right not much in the SDK Docs

oh GetClassInstances(SYSTEM_CLASS_ID, XREFOBJECT_CLASS_ID);

is our own c++ function but a longer one is in the SDK too

Sorry I should have read the whole thread first.

ours is for Xref objects being and can got to Xref scenes with class change.

but not checking deleted from scene but deleted from server.

sorry I didn’t read full story

Page 3 / 3