good morning
I am making a dynamo in which I want to convert the solids exported from the linear work (dwg), convert them to json. I have created all the necessary nodes and I have created the python script with an AI. (because I don’t know PYTHON), but it doesn’t work for me. Does anyone know how to do this because it doesn’t give me any results?
script python
import json
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
Supongamos que el input es un sólido de Dynamo
Puede ser un Solid, Surface, PolySurface, etc.
inputSolid = IN[0]
Función para obtener las propiedades del sólido
def get_solid_properties(solid):
properties = {}
# Obtener el tipo de objeto
properties['type'] = type(solid).__name__
# Obtener el volumen si es un sólido
if hasattr(solid, 'Volume'):
properties['volume'] = solid.Volume
# Obtener el área si es un sólido o superficie
if hasattr(solid, 'Area'):
properties['area'] = solid.Area
# Obtener la cantidad de caras si es un sólido
if hasattr(solid, 'Faces'):
properties['num_faces'] = len(solid.Faces)
# Obtener el bounding box
if hasattr(solid, 'BoundingBox'):
bbox = solid.BoundingBox
properties['bounding_box'] = {
'min_point': {'x': bbox.MinPoint.X, 'y': bbox.MinPoint.Y, 'z': bbox.MinPoint.Z},
'max_point': {'x': bbox.MaxPoint.X, 'y': bbox.MaxPoint.Y, 'z': bbox.MaxPoint.Z}
}
return properties
Obtener las propiedades del sólido
solid_properties = get_solid_properties(inputSolid)
Convertir a JSON
solid_json = json.dumps(solid_properties, indent=4)
Salida del JSON como string
OUT = solid_json


