Skip to content

Commit d25a0d8

Browse files
gonzalocasasclaude
andcommitted
feat(ghpython): Cf_InverseKinematics warns on wired-but-None inputs
If `planner` or `target` is wired (SourceCount > 0) but the upstream returned None, surface a warning naming the input — typically means the upstream component itself failed (e.g. AnalyticalKinematicsPlanner returning None when its solver doesn't accept the loaded cell). The old silent `return None` made it hard to tell whether IK was broken or simply not given a usable input. Unwired inputs stay silent so the canvas isn't noisy while the user is still building it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent ff5d48d commit d25a0d8

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • src/compas_fab/ghpython/components_cpython/Cf_InverseKinematics

src/compas_fab/ghpython/components_cpython/Cf_InverseKinematics/code.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@
4040

4141
class InverseKinematicsComponent(Grasshopper.Kernel.GH_ScriptInstance):
4242
def RunScript(self, planner, target, start_state, group: str):
43-
if not (planner and target):
43+
if planner is None or target is None:
44+
# Warn only when the input *is* wired but the upstream returned
45+
# None (i.e. upstream silently failed). If nothing is wired, the
46+
# user is still building the canvas — staying quiet keeps it clean.
47+
for name, value in (("planner", planner), ("target", target)):
48+
if value is None:
49+
param = next(p for p in ghenv.Component.Params.Input if p.Name == name) # noqa: F821
50+
if param.SourceCount > 0:
51+
warning(ghenv.Component, "{} input is wired but received None; check the upstream component for errors.".format(name)) # noqa: F821
4452
return None
4553

4654
if not isinstance(target, Target):

0 commit comments

Comments
 (0)