Jump to content

[LE] Export list of all objects in cell for each cell in worldspace?


Recommended Posts

Good evening everybody!

 

I want to create a list with all the objects in a cell and their coordinates and scale for each cell in a given worldspace.

So the output (a text file or a csv file) would look something like this, one line for each object in the cell:

 

ObjectType RefID ObjectName PosX PosY PosZ RotX RotY RotZ Scale

 

 

Is there a way to do this with a xEdit script?

Or do I have to go every cell and do this "by hand"?

 

Any help would be appreciated!

Link to comment
Share on other sites

I'm not familiar with xEdit scripting, but you can do it with a papyrus script:

 

Formlist Property MyCells Auto 

Event OnInit()
    Int i = MyCells.GetSize()
    While i > 0 
        i -= 1 
        Cell CurrentCell = MyCells.GetAt(i) as Cell 
        If CurrentCell
            TraceCellObjData(CurrentCell) 
        EndIf 
    EndWhile
EndEvent

Function TraceCellObjData(Cell akCell)
    Debug.Trace("Cell ID: " + akCell.GetFormId())
    Int i = akCell.GetNumRefs() 
    While i > 0 
        i -= 1 
        ObjectReference Obj = akCell.GetNthRef(i) 
        String S = (Obj.GetType() + " " + Obj.GetFormId() + " " + Obj.GetDisplayName() + " " + Obj.GetPositionX() + " " + Obj.GetPositionY() + " " + Obj.GetPositionZ() + \
        " " + Obj.GetAngleX() + " " + Obj.GetAngleY() + " " + Obj.GetAngleZ() + " " + Obj.GetScale())
        
        Debug.Trace(S)
    EndWhile
EndFunction

If you want to wrtie to a txt file, instead you can use MiscUtil.WriteToFile from the PapyrusUtil mod.

 

Edit: Forgot to mention it requires SKSE

Link to comment
Share on other sites

And what would I give this scipt as a property?

The worldspace that I want to "scan"?

A worldspace is basically a collection of cells, kind of like "FormList" of cells, right?

 

Or do I have to manually create a FormList and add EVERY SINGLE CELL in the worldspace I want to "scan" to it by hand?

 

The Debug.Trace() function writes it to the debug log file which is a text file, so that will work fine!

 

I will try this, thanks!

Edited by YouDoNotKnowMyName
Link to comment
Share on other sites

To add cells to a formlist, open the cell view in the CK, open your formlist and click and drag them into the list. Unfortunately you have to drag them all in individually. Another option is to use SkyPal: https://www.nexusmods.com/skyrimspecialedition/mods/43925 to get all references in the game, then only print if it's in the world space.

 

WorldSpace Property MyWorldSpace Auto


Event OnInit() 
    ObjectReference[] AllRefs = SkyPal_References.all() ;get all object references in the game.
    Int i = AllRefs.Length 
    While i > 0 
        i -= 1 
        ObjectReference Obj = AllRefs[i] 
        If Obj.GetWorldSpace() == MyWorldSpace
            String S = (Obj.GetType() + " " + DbMiscFunctions.ConvertIntToHex(Obj.GetFormId()) + " " + Obj.GetDisplayName() + " " + Obj.GetPositionX() + " " + Obj.GetPositionY() + " " + Obj.GetPositionZ() + \
            " " + Obj.GetAngleX() + " " + Obj.GetAngleY() + " " + Obj.GetAngleZ() + " " + Obj.GetScale())
            
            Debug.Trace(S)
        Endif 
    EndWhile


    Debug.MessageBox("Done Printing")
EndEvent

 

Note: this also requires my mod Dylbills Papyrus Functions https://www.nexusmods.com/skyrimspecialedition/mods/65410 to convert the int form ID to hex form ID. And Skypal is only available on SSE. This could also take a while as it would have to check every reference in game.
Link to comment
Share on other sites

So the code that you just posted would work with Skyrim SE and it would require the SKSE for SE, Skypal and your Papyrus function mod, right?

Good thing I just bought SE, it was on sale recently ...

 

This could also take a while as it would have to check every reference in game.

 

No problem, I would just let it run over night or while I am at work ...

Edited by YouDoNotKnowMyName
Link to comment
Share on other sites

GetType() as a SKSE function. Make sure the script source files are in the correct location. In SSE they moved source scripts to Data/Source/Scripts while in LE they are in Data/Scripts/Source. Copy all the .psc files to Data/Source/Scripts for SSE

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...