浏览代码

UI: make curve pin child of curve

this change is only to make the outliner prettier.
Joseph Brandenburg 6 月之前
父节点
当前提交
9894b171fc
共有 1 个文件被更改,包括 18 次插入1 次删除
  1. 18 1
      xForm_containers.py

+ 18 - 1
xForm_containers.py

@@ -900,6 +900,22 @@ class xFormCurvePin(MantisNode):
         if curve.type != 'CURVE':
         if curve.type != 'CURVE':
             raise GraphError(f"ERROR: {self} must be connected to curve,"
             raise GraphError(f"ERROR: {self} must be connected to curve,"
                               " not {curve.type}")
                               " not {curve.type}")
+        # we'll limit all the transforms so we can parent it
+        #  because it is annoying to have a cluttered outliner.
+        c = ob.constraints.new("LIMIT_LOCATION")
+        for max_min in ['max','min']:
+            for axis in "xyz":
+                setattr(c, "use_"+max_min+"_"+axis, True)
+                setattr(c, max_min+"_"+axis, 0.0)
+        c = ob.constraints.new("LIMIT_ROTATION")
+        for axis in "xyz":
+            setattr(c, "use_limit_"+axis, True)
+            setattr(c, max_min+"_"+axis, 0.0)
+        c = ob.constraints.new("LIMIT_SCALE")
+        for max_min in ['max','min']:
+            for axis in "xyz":
+                setattr(c, "use_"+max_min+"_"+axis, True)
+                setattr(c, max_min+"_"+axis, 1.0)
         c = ob.constraints.new("FOLLOW_PATH")
         c = ob.constraints.new("FOLLOW_PATH")
         c.target = curve
         c.target = curve
         c.use_fixed_location = True
         c.use_fixed_location = True
@@ -922,7 +938,8 @@ class xFormCurvePin(MantisNode):
         dg = bContext.view_layer.depsgraph
         dg = bContext.view_layer.depsgraph
         dg.update()
         dg.update()
         # and the matrix should be correct now - copy because it may be modified
         # and the matrix should be correct now - copy because it may be modified
-        self.parameters['Matrix'] = ob.matrix_world.copy() 
+        self.parameters['Matrix'] = ob.matrix_world.copy()
+        ob.parent=curve
         print( wrapGreen("Created Curve Pin: ") + wrapOrange(self.bObject.name) )
         print( wrapGreen("Created Curve Pin: ") + wrapOrange(self.bObject.name) )
         self.prepared = True; self.executed = True
         self.prepared = True; self.executed = True