[Closed] What argument do I pass to objXRefMgr.ApplyXRefMaterialsToXRefObjects ?
Hey guys, just a quick and stupid question. I cannot understand what I’m supposed to pass to the function objXRefMgr.ApplyXRefMaterialsToXRefObjects to use it
The documentation says it’s expecting an argument of the form <&maxObject array>objectXRefItems but I’ve tried passing just a list of objects, pointers to objects or xRef records with no avail. I feel like it wants me to reference something already stored in the xRef Manager itself but I have no idea where to find that data.
Any help would be fantastic, thanks!
So I managed to figure it out in the end but I’m not sure how what I’m doing works or if there’s a better method. Could someone explain it perhaps?
-- First we got the xRef Item from the object
xRItem = objxRefMgr.IsNodeXRefed $ -- Returns the item for $ if correct
-- Next we initialized an empty array to hold our maxobjects
xRTmp = #()
-- Now we assign our maxobject to the array using
xRItem.getRootItems &xRTmp
-- Finally we pass this back to the xRef Manager and reload the material
objXrefMgr.ApplyXRefMaterialsToXRefObjects xRTmp
first of all the symbol $ can return undefined (if nothing selected), a node (if only one object selected) or set of selected nodes
if you want to apply XRef materials to all XRef objects in selection it’s safe just do
objXRefMgr.ApplyXRefMaterialsToXRefObjects $
because the method finds all xrefs and uses only them (all other including undefined are ignored)
if you want to check that selected node is XRef object you have to check what is selected:
if selection.count == 1 and objXRefMgr.IsNodeXRefed selection[1] != undefined do
(
objXRefMgr.ApplyXRefMaterialsToXRefObjects selection[1]
)
objXRefMgr.ApplyXRefMaterialsToXRefObjects takes both node array and single node as argument
also you don’t need to use getRootItems or getNodes methods.
you need them only in case if you know IXRefItem and want to know its content (objects)
in your case you already have XRef object(s)
The script is being made to work on a single selected xRef Object, hence the use of $, and I’ve included checks in the full script to handle empty or non-xRef selections.
However whenever I tried passing just the node directly to the ApplyXRefMaterialsToXRefObjects function or passed it an array of nodes I had initialized myself it never worked and just returned OK. I wondered if there might be something I was missing.
For example if I assigned a particular xRefObject to a variable x and then called xRefObjMgr.ApplyXRefMaterialsToXRefObjects x (or #(x) or &x) I have this problem.