# Maxscript help needed

**URL:** <https://forums.chaos.com/t/maxscript-help-needed/56881>\
**Category:** Off-topic\
**Created:** [January 26, 2016, 12:38am UTC](https://forums.chaos.com/t/maxscript-help-needed/56881 "2016-01-26T00:38:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morne](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/morne/32/11335_2.png) [@Morne](https://forums.chaos.com/u/Morne)\
**Post date:** [January 26, 2016, 12:38am UTC](https://forums.chaos.com/t/maxscript-help-needed/56881/1 "2016-01-26T00:38:27Z")

</div>

Hi all

I want to remove any all XREF objects in the scene, then remove the files it is referenced from the current scene. (Because the dialog is not working and I have couple thousand xrefed obects that doesnt exist from 10 files that also doesnt exist)

---

<div class="post-metadata">

**Author:** ![Morne](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/morne/32/11335_2.png) [@Morne](https://forums.chaos.com/u/Morne)\
**Post date:** [January 26, 2016, 1:09pm UTC](https://forums.chaos.com/t/maxscript-help-needed/56881/2 "2016-01-26T13:09:14Z")

</div>

I found this:

```auto

local currentXRefScenesIndexArr = #[COLOR=#66cc66]([/COLOR][COLOR=#66cc66])
[/COLOR][COLOR=#b1b100]for[/COLOR] i = xrefs.getXRefFileCount[COLOR=#66cc66]([/COLOR][COLOR=#66cc66])[/COLOR] to 1 by -1 [COLOR=#b1b100]do
[/COLOR][COLOR=#66cc66](
[/COLOR] append currentXRefScenesIndexArr [COLOR=#66cc66]([/COLOR]xrefs.getXRefFile i[COLOR=#66cc66])[/COLOR].filename
delete [COLOR=#66cc66]([/COLOR]xrefs.getXRefFile i[COLOR=#66cc66])
[/COLOR][COLOR=#66cc66])[/COLOR]

```

But that’s for XREF scenes.  
I’m having a hard time using this

```auto

[I]objXRefs.getAllXRefObjects()[/I]

```

to modify the code and get rid of all xref objects.

Anybody care to lend a hand please?

---

<div class="post-metadata">

**Author:** ![Morne](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/morne/32/11335_2.png) [@Morne](https://forums.chaos.com/u/Morne)\
**Post date:** [January 26, 2016, 10:41pm UTC](https://forums.chaos.com/t/maxscript-help-needed/56881/3 "2016-01-26T22:41:37Z")

</div>

For those interested, this did the trick:  
`delete (for obj in objects where isKindOf obj XRefObject collect obj)`

Thanks to SwordSlayer on CGTalk for that one!
