This Programm saves all GUID’s of the elements with the Localplacements in a txt file.
###########################################################################################################
# Import Libraries
###########################################################################################################
import Base, Core, Geom, Draw, Topo
import OpenLxApp as lx
import OpenLxUI as ui
import OpenLxCmd as cmd
import math
import os
###########################################################################################################
# Defining namespaces
###########################################################################################################
lxstr = Base.StringTool.toString
cstr = Base.StringTool.toStlString
app = lx.Application.getInstance()
doc = app.getActiveDocument()
uiapp = ui.UIApplication.getInstance()
uidoc = uiapp.getUIDocument(doc)
sel = uidoc.getSelection()
###########################################################################################################
# All Elements get selected and saved
###########################################################################################################
sel.selectAll()
elements = uidoc.getSelectedElements()
eplacements = []
print(sys.path[0])
###########################################################################################################
# for each elements the GUID and the localplacemenent get saved in eplacements
###########################################################################################################
for e in elements:
glob_id = e.getGlobalId()
global_id = cstr(glob_id.toString())
place = e.getLocalPlacement()
loc = place.location()
print("global_ID: ", global_id, loc.x(), loc.y(), loc.z())
eplacements.append([global_id, loc.x(), loc.y(), loc.z()])
###########################################################################################################
# the values are written into the txt file
###########################################################################################################
txtstring = sys.path[0]+'/Global_ID_test.txt'
print(txtstring)
txtfile = open(txtstring, "w")
for p in eplacements:
txtfile.write(repr(p[0])+";"+ repr(p[1])+";"+repr(p[2])+";"+ repr(p[3])+"\n")
txtfile.close()
Author: P. Walther