Jump to content

Photo

Export list of all objects in cell for each cell in worldspace?

xedit

  • Please log in to reply
33 replies to this topic

#1
YouDoNotKnowMyName

YouDoNotKnowMyName

    Overseer of Vault 114 / Destroyer of Precombines

  • Members
  • PipPipPipPip
  • 1,902 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!



#2
dylbill

dylbill

    Resident poster

  • Premium Member
  • 2,952 posts

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



#3
YouDoNotKnowMyName

YouDoNotKnowMyName

    Overseer of Vault 114 / Destroyer of Precombines

  • Members
  • PipPipPipPip
  • 1,902 posts

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, 30 May 2022 - 05:21 PM.


#4
YouDoNotKnowMyName

YouDoNotKnowMyName

    Overseer of Vault 114 / Destroyer of Precombines

  • Members
  • PipPipPipPip
  • 1,902 posts

How can I add "cells" from a worldspace to a FormList?



#5
dylbill

dylbill

    Resident poster

  • Premium Member
  • 2,952 posts

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.nexusmod...tion/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.nexusmod...tion/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.


#6
YouDoNotKnowMyName

YouDoNotKnowMyName

    Overseer of Vault 114 / Destroyer of Precombines

  • Members
  • PipPipPipPip
  • 1,902 posts

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, 30 May 2022 - 06:37 PM.


#7
dylbill

dylbill

    Resident poster

  • Premium Member
  • 2,952 posts

Yes that's correct. Don't forget to fill the Worldspace property when attaching it in the creation kit.



#8
YouDoNotKnowMyName

YouDoNotKnowMyName

    Overseer of Vault 114 / Destroyer of Precombines

  • Members
  • PipPipPipPip
  • 1,902 posts

When I try to compile it, the CK says that "GetType()" is not a function or does not exist.

 

I have installed SKSE, Skypal and your Functions mod.



#9
dylbill

dylbill

    Resident poster

  • Premium Member
  • 2,952 posts

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



#10
dylbill

dylbill

    Resident poster

  • Premium Member
  • 2,952 posts

Also fyi GetType() returns an int. Here's what they stand for: https://www.creation...=GetType_-_Form







Also tagged with one or more of these keywords: xedit

IPB skins by Skinbox
Page loaded in: 1.105 seconds