Skip to content

ReadFromD2P: Component output is null although the pieces are read #36

Closed

Description

@fstwn

What happens

ReadFromD2P reads the CSC pieces of the Rhino document and outputs their ComponentPassport, but the Component output (the D2P component, .NET IComponentBase) is null for every piece, also for pieces that are D2P components written by PassportToD2P.

Likely cause (from reading the code, not yet reproduced)

In grasshopper_userobjects_src/DDU_CSC_ReadFromD2P.py, RunScript passes d2p_plane(entry) to read_document (grasshopper_lib/csc_gh/doc.py:307). d2p_plane assumes that the tagged object is the label of the D2P component:

  • it returns None at once when entry['object'].Attributes.Name is empty ("a plain tag of BakeComponents has no name and is not asked");
  • otherwise it calls instance_from_object(entry['object']) and swallows every exception (except Exception: component = None), without a message.

But PassportToD2P no longer puts the convention user text on the label: "D2P commits its label without user text", so the ids are written on the geometry objects of the component, with fresh ObjectAttributes() and no name (see the docstring around DDU_CSC_PassportToD2P.py:94 and _base_object). The tagged objects that tagged_objects(doc) finds are therefore member geometry, not labels: d2p_plane returns None for them, nothing is put into found, and Component.Add(found.get(...)) adds null.

A side effect, if this is right: the placement is then taken from the tag plane (the stored csc_placement), not from the current plane of the D2P component, so a D2P component moved in Rhino after PassportToD2P is read back at its old placement.

Expected

  • For a piece that belongs to a D2P component, Component carries that component and csc_placement follows its current plane.
  • Null only for a plain tag (a piece baked by BakeComponents), as the output description says.
  • A failure to resolve the D2P component is a warning naming the piece, not silent.

Fix sketch

  • Resolve the D2P component from a tagged member object (its parent component / label, as D2P's own member lookup does), not only from a named label; keep the label path for documents written by older releases.
  • Report the exception of instance_from_object as a warning instead of swallowing it.
  • Check whether SyncWithRhinoDoc has the same assumption.

Done when

  • A document written by the current PassportToD2P gives a non-null Component per piece, and moving a D2P component in Rhino changes the csc_placement that is read back.
  • A plain BakeComponents tag still gives null without a warning.
  • Tests in tests/grasshopper for the resolution (member object, label, plain tag), with D2P stubbed; a live check in Rhino 8.
  • Re-exported user object with the next Grasshopper release.

Activity

  1. fstwn commented on Nov 4, 2026

    @fstwn
    ContributorAuthor

    Fixed in 0.6.4.4 (#53). A component made by PassportToD2P and committed with D2P now comes back in the Component output. An element baked by BakeComponents is no D2P component and gives null by design; the null in this report came from such a bake (decision 8.185).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggrasshopper-interfaceIssues regarding the GH interface

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions