PartFeature.shape is immutable in 0.13+

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
jack-not-really
Posts: 14
Joined: Fri Nov 15, 2013 5:30 pm

PartFeature.shape is immutable in 0.13+

Post by jack-not-really »

Up to FreeCAD 0.12 it was possible to change the shape matrix of a PartFeature (and other properties).
In FreeCAD 0.13+ PartFeature.shape is immutable.

Because I am using FreeCAD without GUI, I transfer all geometry informations from shapes to my application. This is done by tessellation for all faces and reading all Edges e.g.
I need "local" geometry. Transformations are handled separate by transferring the shape Matrix.

In 0.12 I could:
- save the shape.Matrix
- reset shape.Matrix to an identity matrix
- .. tessellate e.g.
- restore the "old" matrix

the only way I see in 0.13+ is
- to work with a shape.copy() to reset the matrix
- to transform all vertex with the inverse matrix
Both option are very slow and not really nice.
Has someone a better solution?

Thanks for your help.
Jack-not-really
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PartFeature.shape is immutable in 0.13+

Post by wmayer »

Instead of setting the matrix to the shape object you can set it to the part feature. This has exactly the same effect because in FreeCAD the placement of a part feature is always synchronized with the placement of its shape.
jack-not-really
Posts: 14
Joined: Fri Nov 15, 2013 5:30 pm

Re: PartFeature.shape is immutable in 0.13+

Post by jack-not-really »

wmayer wrote:Instead of setting the matrix to the shape object you can set it to the part feature. This has exactly the same effect because in FreeCAD the placement of a part feature is always synchronized with the placement of its shape.
Yes, I know. But "only" for the Placement. This works as long as the matrix is orthonormal. And it fires a onChange event for the placement. But never mind.

This was discussed here several times. No reply needed. Thanks!
jack-not-really
Posts: 14
Joined: Fri Nov 15, 2013 5:30 pm

Re: PartFeature.shape is immutable in 0.13+ addendum

Post by jack-not-really »

I was wrong and sold again!

Code: Select all

shape=ShapeParent.Shape
ShapeParent.Placement=FreeCAD.Placement(FreeCAD.Matrix()) 
shape.Matrix will not be changed instead of ShapeParent.Shape.Matrix
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: PartFeature.shape is immutable in 0.13+

Post by wmayer »

Be careful!
shape=ShapeParent.Shape
Here you have a new reference to the underlying shape object.
ShapeParent.Placement=FreeCAD.Placement(FreeCAD.Matrix())
This can cause the part feature to recompute itself and thus creates a new shape object. The above reference points to the old shape which doesn't belong to the part feature any more
Post Reply