Rhino Python: Identify Worksession File of Intersected Geometry

Hi everyone,

I am looking for some advice regarding Rhino Worksession files and Python scripting.

I have a file called all.rws, in which 00-section.3dm is set as the active model. In addition, I have four other models loaded into the Worksession:

  • CNS.3dm
  • WTB.3dm
  • INT.3dm
  • EXT.3dm

The 00-section.3dm file contains several clipping planes. These clipping planes intersect with geometry from the other models loaded in the Worksession.

I have created a script that generates sections using the clipping planes and then flattens the resulting curves. However, I would like to know if there is a way for the script to identify which Worksession file the geometry being intersected comes from.

Based on the source file, I would then like the script to:

  1. Identify which Worksession file the intersected geometry belongs to (for example, CNS.3dm). If possible in one go.
  2. Place the resulting section curves on the corresponding layer (for example, a layer named CNS).
  3. Export the section using a filename based on the source model and/or the name of the clipping plane.

For example, if a clipping plane intersects geometry from CNS.3dm, I would like the resulting section curves to be placed on the CNS layer and exported with a filename that includes CNS and the name of the clipping plane.

Is this possible in Rhino Python? If so, what would be the best way to identify the source Worksession file of the intersected geometry?

Any advice or examples would be greatly appreciated.

Thanks in advance!

This works, but it’s quite slow to access the worksession file.

#! python 3
import Rhino

def get_worksession_path(guid):
	rhobj = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid)
	rmsn = rhobj.ReferenceModelSerialNumber
	path = Rhino.RhinoDoc.ActiveDoc.Worksession.ModelPathFromSerialNumber(rmsn)
	return path

Thanks, this works perfectly! It correctly identifies which worksession file the geometry comes from. This is exactly what I was looking for. Much appreciated!