lost functionality - GeomBSplineSurface::Restore / Save
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
lost functionality - GeomBSplineSurface::Restore / Save
[EDIT] requires Silk addon to follow along
when i load the model loads with a clean model tree, but there is some kind of error in the report view > GeomBSplineSurface::Restore the three errors correspond to the three "CubicNStarSurface_NStar66" document objects.
if i delete one of these objects, i can remake it from the underlying "ControlGridNStar66_NSub" object this does not trigger any new errors in the report view.
when i save the modified file however, i get a new error unlike the three loading errors, i get only one error here, for the re-created surface.
[continued]
when i load the model loads with a clean model tree, but there is some kind of error in the report view > GeomBSplineSurface::Restore the three errors correspond to the three "CubicNStarSurface_NStar66" document objects.
if i delete one of these objects, i can remake it from the underlying "ControlGridNStar66_NSub" object this does not trigger any new errors in the report view.
when i save the modified file however, i get a new error unlike the three loading errors, i get only one error here, for the re-created surface.
[continued]
Last edited by emills2 on Sun Mar 26, 2023 10:40 pm, edited 1 time in total.
Re: lost functionality - GeomBSplineSurface::Restore / Save
when i open the modified file,
these objects are created and added to the documents as
the above is a generic format for all workbench commands, and the specific function is "AN.CubicNStarSurface_NStar66(a, NStar66)"
which is defined like this
the key steps here are:
-a python feature object "a" is added to the doc as "CubicNStarSurface_NStar66"
-this object "a" is passed along to the function "AN.CubicNStarSurface_NStar66(a, NStar66)" along with the parameter "NStar66"
-the function "CubicNStarSurface_NStar66" adds two parameters to the object "a": NStarGrid(receives the parameter NStar66), and Nsurf (which will hold the output geometry)
-the input parameter is massaged a bit (float list to Base.Vector, etc)
-NSurf is is set to be a list
-for each item in NSurf, NURBS_Cubic_66_surf() is called, which itself returns a Part.BSplineSurface()
-Nsurf is then assigned to be the Shape of the python feature object.
fp.Shape = Part.Shape(fp.NSurf)
this line is how is basically always handle the assigning of the shape to my workbench objects. all the grids work this way for example: build a list of lines, and assign that list as object.Shape
so the object's Shape points to NSurf, which is a list of Part.BSplineSurface() objects. at this point we have a feature python object with 2 attributes, one that holds the input parameter, and one that holds the results as a list of Part.BSplineSurface() objects.
everything works up to this point. the object is added to the document, and the Shape is rendered correctly.
but then it doesn't save correctly. Upon reopening the file, it appears a geometry section of the xml was never written correctly.
I think something has changed in the rules for saving, but i don't know where to start looking.
Any help understanding the situation and how to fix it would be greatly appreciated. The error seems to be happening at a much deeper level than anything i have ever dealt with directly. the error in the report view is not very decriptive.
i get the previous GeomBSplineSurface::Restore error, as well as a fatal error for the surface i attempted to re-create
so the "GeomBSplineSurface::Save" error leave the file worse off than i started.these objects are created and added to the documents as
Code: Select all
from __future__ import division # allows floating point division from integers
import FreeCAD, Part, math
from FreeCAD import Base
from FreeCAD import Gui
import ArachNURBS as AN
# Locate Workbench Directory
import os, Silk_dummy
path_Silk = os.path.dirname(Silk_dummy.__file__)
path_Silk_icons = os.path.join( path_Silk, 'Resources', 'Icons')
class CubicNStarSurface_NStar66():
def Activated(self):
NStar66 = Gui.Selection.getSelection()[0]
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","CubicNStarSurface_NStar66")
AN.CubicNStarSurface_NStar66(a, NStar66)
a.ViewObject.Proxy=0 # just set it to something different from None (this assignment is needed to run an internal notification)
a.ViewObject.DisplayMode = u"Shaded"
a.ViewObject.ShapeColor = (0.33,0.67,1.00)
FreeCAD.ActiveDocument.recompute()
def GetResources(self):
return {'Pixmap' : path_Silk_icons + '/CubicNStarSurface_NStar66.svg', 'MenuText': 'CubicNStarSurface_NStar66', 'ToolTip': 'CubicNStarSurface_NStar66'}
Gui.addCommand('CubicNStarSurface_NStar66', CubicNStarSurface_NStar66())
which is defined like this
Code: Select all
class CubicNStarSurface_NStar66:
def __init__(self, obj , NStarGrid):
''' Add the properties '''
FreeCAD.Console.PrintMessage("\nCubicNStarSurface_NStar66 Init\n")
obj.addProperty("App::PropertyLink","NStarGrid","CubicNStarSurface_NStar66","control grid star").NStarGrid = NStarGrid
obj.addProperty("Part::PropertyGeometryList","NSurf","CubicNStarSurface_NStar66","N Cubic Surfaces").NSurf
obj.Proxy = self
def HomogeneousGrids(self, fp, N):
HomogeneousGrids = [0] * N
for i in range(N):
HGrid_i = [0] *36
for j in range(36):
# convert the float list from NStarGrid back to Base.Vector.
HGrid_i[j] = [Base.Vector(fp.NStarGrid.StarGrid[i][j][0][0],fp.NStarGrid.StarGrid[i][j][0][1],fp.NStarGrid.StarGrid[i][j][0][2]), fp.NStarGrid.StarGrid[i][j][1]]
HomogeneousGrids[i] = HGrid_i
return HomogeneousGrids
def makeNSurf(self, fp, HomogeneousGrids, N):
NSurf = [0] * N
for i in range(N):
NSurf[i] = NURBS_Cubic_66_surf(HomogeneousGrids[i])
return NSurf
def execute(self,fp):
# cast [x ,y, z] in linked NstarGrid back to Base.Vector
HomogeneousGrids = self.HomogeneousGrids(fp, fp.NStarGrid.N)
#loop over the homogeneous grids to make the surfaces
NSurf = self.makeNSurf(fp, HomogeneousGrids, fp.NStarGrid.N)
fp.NSurf = NSurf
fp.Shape = Part.Shape(fp.NSurf)
-a python feature object "a" is added to the doc as "CubicNStarSurface_NStar66"
-this object "a" is passed along to the function "AN.CubicNStarSurface_NStar66(a, NStar66)" along with the parameter "NStar66"
-the function "CubicNStarSurface_NStar66" adds two parameters to the object "a": NStarGrid(receives the parameter NStar66), and Nsurf (which will hold the output geometry)
-the input parameter is massaged a bit (float list to Base.Vector, etc)
-NSurf is is set to be a list
-for each item in NSurf, NURBS_Cubic_66_surf() is called, which itself returns a Part.BSplineSurface()
-Nsurf is then assigned to be the Shape of the python feature object.
fp.Shape = Part.Shape(fp.NSurf)
this line is how is basically always handle the assigning of the shape to my workbench objects. all the grids work this way for example: build a list of lines, and assign that list as object.Shape
so the object's Shape points to NSurf, which is a list of Part.BSplineSurface() objects. at this point we have a feature python object with 2 attributes, one that holds the input parameter, and one that holds the results as a list of Part.BSplineSurface() objects.
everything works up to this point. the object is added to the document, and the Shape is rendered correctly.
but then it doesn't save correctly. Upon reopening the file, it appears a geometry section of the xml was never written correctly.
I think something has changed in the rules for saving, but i don't know where to start looking.
Any help understanding the situation and how to fix it would be greatly appreciated. The error seems to be happening at a much deeper level than anything i have ever dealt with directly. the error in the report view is not very decriptive.
Re: lost functionality - GeomBSplineSurface::Restore / Save
https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L4544
Save & Restore is not yet implemented for any surface geometry types.
Save & Restore is not yet implemented for any surface geometry types.
Re: lost functionality - GeomBSplineSurface::Restore / Save
thanks for the fast reply Werner. I'm very confused, so i must be misunderstanding you. it worked for years, in the sense that this model below has 99 saved versions??? i created the objects, they were added to the document, they displayed, they saved, they opened correctly...there is no way that i manually recreated all these objects in each file. it's not even possible because the dependency goes sketch>poly>grid>surface>grid>grid>surface....you can't just save the file without the surfaces, reopen and recreate the surfaces "real quick". the surfaces are embedded throughout.wmayer wrote: ↑Sun Mar 26, 2023 10:44 pm https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L4544
Save & Restore is not yet implemented for any surface geometry types.
i have models with several hundred saved versions? And they actually open and render correctly (with error messages). the only real trouble starts when trying to work further on them now.
Re: lost functionality - GeomBSplineSurface::Restore / Save
Is this "Save & Restore" something new in the last few years, which wasn't needed before? and somehow before it just worked?wmayer wrote: ↑Sun Mar 26, 2023 10:44 pm https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L4544
Save & Restore is not yet implemented for any surface geometry types.
Re: lost functionality - GeomBSplineSurface::Restore / Save
like maybe before it just recomputed every time instead of saving the surface? is there a way i can prevent the saving of surfaces? that way it just recomputes? that is very possibly what was happening before. that would be fine really.emills2 wrote: ↑Sun Mar 26, 2023 11:01 pmIs this "Save & Restore" something new in the last few years, which wasn't needed before? and somehow before it just worked?wmayer wrote: ↑Sun Mar 26, 2023 10:44 pm https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L4544
Save & Restore is not yet implemented for any surface geometry types.
Re: lost functionality - GeomBSplineSurface::Restore / Save
i mean, obviously it would be very nice to save all surface geometry data, although an option to not do so would still be nice (for smaller files on disk)
but since right now we can't, a smaller file with a longer load time due to recompute would be better than a broken file.
but since right now we can't, a smaller file with a longer load time due to recompute would be better than a broken file.
Re: lost functionality - GeomBSplineSurface::Restore / Save
if instead of deleting/recreating one of the complex 'multi-patch' objects, i just redo a single surface, everything works.
-a blue surface deleted
-redone in pink
-saved with no issues
now we reopen the modified file -the file reopens.
-the errors from opening the original file are gone!!!
-the new pink surface is fine
shown above:-a blue surface deleted
-redone in pink
-saved with no issues
now we reopen the modified file -the file reopens.
-the errors from opening the original file are gone!!!
-the new pink surface is fine
Re: lost functionality - GeomBSplineSurface::Restore / Save
so this seems to only affect the case where the shape is a list of surfaces, but if only a single Part.BSplineSurface() is assigned, there is no visible issue.
Re: lost functionality - GeomBSplineSurface::Restore / Save
this model
i edited the very first sketch in the dependency hierarchy. it updated correctly. 'save as' gave no errors reopening the document gives no errors these files aren't perfect by any means. sketcher behavior is slightly different then before, and previously good sketches are sometimes overconstrained. i'm not worried about that, and i don't mind reviewing the sketches and fixing them.
the point of interest here is that the only difference between these files and the problem file is that i have objects whose shape is a list of Part.BSplineSurface(), instead of a single Part.BSplineSurface(). the only diffrence i can identify anyways.
had no 'multi-surface' objects in it. meaning each document object has at most one Part.BSplineSurface() in its Shape. it loads correctly (some warnings)i edited the very first sketch in the dependency hierarchy. it updated correctly. 'save as' gave no errors reopening the document gives no errors these files aren't perfect by any means. sketcher behavior is slightly different then before, and previously good sketches are sometimes overconstrained. i'm not worried about that, and i don't mind reviewing the sketches and fixing them.
the point of interest here is that the only difference between these files and the problem file is that i have objects whose shape is a list of Part.BSplineSurface(), instead of a single Part.BSplineSurface(). the only diffrence i can identify anyways.