length of the spline does not work after apllying hooks #72025

Closed
opened 2019-11-28 20:39:26 +01:00 by ML · 15 comments

System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.30

Blender Version
Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-11-20 14:27, hash: 26bd5ebd42
Worked: (optional)

Short description of error
Let's create any of the splines in blender (nurbs, bezier) and then use know function: bpy.data.curves["NurbsCurve"].splines- [x].calc_length()
It's smoothly working. But after you apply hook modifier and move the empty somewhere, length does not change the value. Thant problem is crucial for custom squash with spline IK.

Exact steps for others to reproduce the error
create spline >[edit mode] > select one of the vertices > ctrl+h > hook to new object > [object mode] > to Python console copy: bpy.data.curves["NurbsCurve"].splines- [x].calc_length() with correct name "NurbsCurve" or "BezierCurve" > a value > move the empty somewhere > again use console with same code > it gives same value even the legth was changed

**System Information** Operating system: Windows-10-10.0.18362 64 Bits Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.30 **Blender Version** Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-11-20 14:27, hash: `26bd5ebd42` Worked: (optional) **Short description of error** Let's create any of the splines in blender (nurbs, bezier) and then use know function: bpy.data.curves["NurbsCurve"].splines- [x].calc_length() It's smoothly working. But after you apply hook modifier and move the empty somewhere, length does not change the value. Thant problem is crucial for custom squash with spline IK. **Exact steps for others to reproduce the error** create spline >[edit mode] > select one of the vertices > ctrl+h > hook to new object > [object mode] > to Python console copy: bpy.data.curves["NurbsCurve"].splines- [x].calc_length() with correct name "NurbsCurve" or "BezierCurve" > a value > move the empty somewhere > again use console with same code > it gives same value even the legth was changed
Author

Added subscriber: @MarcelLegindi

Added subscriber: @MarcelLegindi

#81091 was marked as duplicate of this issue

#81091 was marked as duplicate of this issue

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Germano Cavalcante self-assigned this 2019-11-29 13:49:08 +01:00

As we can see in the code, calc_length is executed on the data of the object. That is, with no effect of any modifier.
Different objects can have the same data, so there is no way for the code to know which modified object it should calculate the length of.

Blender 2.8 has a bug with curve modifiers (#71055) changing all objects with the same data. But that will be fixed.

As we can see in the code, `calc_length` is executed on the `data` of the object. That is, with no effect of any modifier. Different objects can have the same `data`, so there is no way for the code to know which modified object it should calculate the length of. Blender 2.8 has a bug with curve modifiers (#71055) changing all objects with the same `data`. But that will be fixed.
Author

Well, I don't understand, is it functional or not? When I use hook and move .. the calc_length does not work precise - so I do something wrong? If so, what exactly?

Well, I don't understand, is it functional or not? When I use hook and move .. the calc_length does not work precise - so I do something wrong? If so, what exactly?
Author

there is the proof - this is not working and its a bug. If I understand the usage.

zk01.gif

there is the proof - this is not working and its a bug. If I understand the usage. ![zk01.gif](https://archive.blender.org/developer/F8183333/zk01.gif)

To explain further...

We have: object, data and modifier.
Object = data + modifiers
The object is the Curve (NurbsCurve).
The data are the splines of the Curve (the data is confusingly also called NurbsCurve on this object, but the name can be changed in the properties).
The modifier is Hook.

calc_length is a function of the data and not of the object.

We can have more than one object with the same data:
ObjectA = data + modifiersA
ObjectB = data + modifiersB

Objects can have different lengths but the data remains the same.

To explain further... We have: object, data and modifier. Object = data + modifiers The object is the Curve (NurbsCurve). The data are the splines of the Curve (the data is confusingly also called NurbsCurve on this object, but the name can be changed in the properties). The modifier is Hook. `calc_length` is a function of the data and not of the object. We can have more than one object with the same data: ObjectA = data + modifiersA ObjectB = data + modifiersB Objects can have different lengths but the data remains the same.
Author

I see, thank you. So is there any option how to measure the spline .. or some other method how to make custom squash besides ratio(spline_length/hooked_spline_length)*scaleY_of_the_bone ? ... you know if you have 15spine bones.. or 2 BBones and scale it properly by distance from the root?

I see, thank you. So is there any option how to measure the spline .. or some other method how to make custom squash besides ratio(spline_length/hooked_spline_length)*scaleY_of_the_bone ? ... you know if you have 15spine bones.. or 2 BBones and scale it properly by distance from the root?

I don't know off the top of my head (you may have to create a temporary mesh as a last resort).

I don't know off the top of my head (you may have to create a temporary mesh as a last resort).
Author

Ok thank you very much ..But that's a pity. May I suggest to make it like new function somewhere in this forum? You know, control spline IK properly and fast is crucial for any cartoon character in rigging and trying to measure it by an array modificators is very slow for complex rigs.

Ok thank you very much ..But that's a pity. May I suggest to make it like new function somewhere in this forum? You know, control spline IK properly and fast is crucial for any cartoon character in rigging and trying to measure it by an array modificators is very slow for complex rigs.

Added subscriber: @Josephbburg

Added subscriber: @Josephbburg

Is it possible to get an evaluated version of the curve data (not the mesh)?

Anyhow, about a year ago, I made a right-click-select proposal related to this problem. https://blender.community/c/rightclickselect/4ncbbc/ In the meantime, I've come up with a pretty good solution to the measurement problem for my addon, Chain Tools, which I'd be happy to share if you're interested.

When measuring a curve for a rig, especially for squash and stretch, it isn't necessary to get the actual measurements- you only really need to compare the base length to the posed length (for the y-axis scale). Then you can take the reciprocal of this measurement to set the scale for the x and z axes. I usually create a dummy spline IK that is set to space the bones out evenly. I make sure to apply the pose to edit mode a few times to prevent its length from changing when changing into pose mode. Then I can use the y-scale (local space) of any bone in the chain to measure the length of the curve - if the curve starts out at 5 units, and the bone's scale is 1.5, then I know the length of the curve is 5 * 1.5 = 7.5. This is usually good enough for whatever I want to do.

Is it possible to get an evaluated version of the curve data (not the mesh)? Anyhow, about a year ago, I made a right-click-select proposal related to this problem. https://blender.community/c/rightclickselect/4ncbbc/ In the meantime, I've come up with a pretty good solution to the measurement problem for my addon, Chain Tools, which I'd be happy to share if you're interested. When measuring a curve for a rig, especially for squash and stretch, it isn't necessary to get the actual measurements- you only really need to compare the base length to the posed length (for the y-axis scale). Then you can take the reciprocal of this measurement to set the scale for the x and z axes. I usually create a dummy spline IK that is set to space the bones out evenly. I make sure to apply the pose to edit mode a few times to prevent its length from changing when changing into pose mode. Then I can use the y-scale (local space) of any bone in the chain to measure the length of the curve - if the curve starts out at 5 units, and the bone's scale is 1.5, then I know the length of the curve is 5 * 1.5 = 7.5. This is usually good enough for whatever I want to do.
Author

Thank you very much, Joseph. So if I understand right, you compare true (start) length of the spline (without modifiers) with IK-spline chain length with scaleY turn on, by basic bone length * its scale after stretching.

I asked in blender.stackexchange if somebody wants more solutions: https://blender.stackexchange.com/questions/159714/custom-squash-and-stretch-without-spline-length-ratio/159719?noredirect=1#comment270625_159719

Thank you very much, Joseph. So if I understand right, you compare true (start) length of the spline (without modifiers) with IK-spline chain length with scaleY turn on, by basic bone length * its scale after stretching. I asked in blender.stackexchange if somebody wants more solutions: https://blender.stackexchange.com/questions/159714/custom-squash-and-stretch-without-spline-length-ratio/159719?noredirect=1#comment270625_159719
Member

Added subscribers: @elie, @lichtwerk

Added subscribers: @elie, @lichtwerk
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#72025
No description provided.