[SOLVED]Solid created by shell-faces-tollerance-sew has problem. Sew or Tollerance dosen't create solid?
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
[SOLVED]Solid created by shell-faces-tollerance-sew has problem. Sew or Tollerance dosen't create solid?
My EdgeExtend supposed to create solid .. my code should create a solid but when I try with python to check it if it is solid .. it fails.
I upload the file and the picture of the code I used. And I checked even with defeaturing geometry check ...it should be ok. but it isn't.
bug in Part WB? or what?
what you see in the left is the answer of the defeaturing WB - geometry check. and in the right is the code i used to check but it says "Shell"
thanks in advance.
I upload the file and the picture of the code I used. And I checked even with defeaturing geometry check ...it should be ok. but it isn't.
bug in Part WB? or what?
what you see in the left is the answer of the defeaturing WB - geometry check. and in the right is the code i used to check but it says "Shell"
thanks in advance.
- Attachments
-
- test.JPG (206.8 KiB) Viewed 1265 times
-
- test.FCStd
- (5.31 KiB) Downloaded 11 times
Last edited by mariwan on Thu Dec 02, 2021 6:11 pm, edited 1 time in total.
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: Would you please let me know why it is wrong?
Can confirm your object is a shell. Just "drill" it by cutting a box or cylinder and you'll see.
Maybe it comes from the way you create it, but hard to say without any more clue.
Maybe it comes from the way you create it, but hard to say without any more clue.
Re: Would you please let me know why it is wrong?
Code: Select all
soldObjShape = _part.Solid(_part.Shell(_resultFace))
newObj = App.ActiveDocument.addObject("Part::Feature","comp")
newObj.Shape = soldObjShape
newObj = self.sewShape(newObj)
newObj = self.setTolerance(newObj)
for face in self.newFaces:
App.ActiveDocument.removeObject(face.Name)
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: Would you please let me know why it is wrong?
Those 2 lines don't make much sense ATM as they are redefining your 'newObj' variable with some functions that I don't see (don't know type of 'self' and if functions are native or custom).
Code: Select all
newObj = self.sewShape(newObj)
newObj = self.setTolerance(newObj)
Code: Select all
Part.show(Part.Solid(App.ActiveDocument.Solid.Shape))
BTW : Defeaturing tells you "Solid" because it is the name of the object, not because it is an actual solid.
Re: Would you please let me know why it is wrong?
Code: Select all
def setTolerance(self, sel):
try:
if hasattr(sel, 'Shape'):
ns = sel.Shape.copy()
new_tol = 0.001
ns.fixTolerance(new_tol)
sel.ViewObject.Visibility = False
sl = App.ActiveDocument.addObject("Part::Feature", "Solid")
sl.Shape = ns
g = Gui.ActiveDocument.getObject(sel.Name)
g.ShapeColor = sel.ViewObject.ShapeColor
g.LineColor = sel.ViewObject.LineColor
g.PointColor = sel.ViewObject.PointColor
g.DiffuseColor = sel.ViewObject.DiffuseColor
g.Transparency = sel.ViewObject.Transparency
App.ActiveDocument.removeObject(sel.Name)
sl.Label = 'Extended'
return sel
except Exception as err:
App.Console.PrintError("'sewShape' Failed. "
"{err}\n".format(err=str(err)))
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(exc_type, fname, exc_tb.tb_lineno)
# Based on the sewShape from De-featuring WB,
# but simplified- Thanks for the author
def sewShape(self, sel):
"""[Fix issues might be in the created object]
Args:
sel ([3D Object]): [Final object that needs repair.
Always new object creates as result of sew]
"""
try:
if hasattr(sel, 'Shape'):
sh = sel.Shape.copy()
sh.sewShape()
sl = App.ActiveDocument.addObject("Part::Feature", "compSolid")
sl.Shape = sh
g = Gui.ActiveDocument.getObject(sl.Name)
g.ShapeColor = Gui.ActiveDocument.getObject(sel.Name).ShapeColor
g.LineColor = Gui.ActiveDocument.getObject(sel.Name).LineColor
g.PointColor = Gui.ActiveDocument.getObject(sel.Name).PointColor
g.DiffuseColor = Gui.ActiveDocument.getObject(
sel.Name).DiffuseColor
g.Transparency = Gui.ActiveDocument.getObject(
sel.Name).Transparency
App.ActiveDocument.removeObject(sel.Name)
App.ActiveDocument.recompute()
return (sl)
except Exception as err:
App.Console.PrintError("'sewShape' Failed. "
"{err}\n".format(err=str(err)))
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(exc_type, fname, exc_tb.tb_lineno)
I tested in Part WB the tool - >Make Solid .. it convert it to solid .. but I do the same sequence that tool tells me.
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: Would you please let me know why it is wrong?
IMO, setTolerance returns 'sel' instead of 'sl'.
- Shalmeneser
- Veteran
- Posts: 9580
- Joined: Wed Dec 23, 2020 12:04 am
- Location: Fr
Re: Would you please let me know why it is wrong?
Could you choose more specific title for your post, please ?
Re: Would you please let me know why it is wrong?
Yes you are right.
But for fixing the solid problem .. I needed to recreate a solid object again. Seems that sew or tolerance shapes are not solid. Regarding the Defeature.. I was not clear but I used the checking function for solid .. so it was telling me that it was ok .. you can try it.
Here my final code which works.
Code: Select all
def recreateObject(self):
# FIXME:
# Here we have
# We try to create a wire-closed to replace the sides we delete.
# This will be way to complex . with many bugs :(
try:
App.ActiveDocument.removeObject(self.newEdge.Name)
_result = []
_resultFace=[]
_result.clear()
for faceVert in self.savedVertices:
convert = []
for vert in faceVert:
convert.append(vert.Point)
_Newvertices = convert
newPolygon = _part.makePolygon(_Newvertices, True)
convert.clear()
newFace = _part.makeFilledFace(newPolygon.Edges)
if newFace.isNull():
raise RuntimeError('Failed to create face')
nFace = App.ActiveDocument.addObject("Part::Feature", "nFace")
nFace.Shape = newFace
_result.append(nFace)
_resultFace.append(newFace)
self.newFaces = _result
solidObjShape = _part.Solid(_part.Shell(_resultFace))
newObj = App.ActiveDocument.addObject("Part::Feature", "comp")
newObj.Shape = solidObjShape
newObj = self.sewShape(newObj)
newObj = self.setTolerance(newObj)
solidObjShape = _part.Solid(newObj.Shape)
final = App.ActiveDocument.addObject("Part::Feature", "Extended")
final.Shape = solidObjShape
App.ActiveDocument.removeObject(newObj.Name)
for face in self.newFaces:
App.ActiveDocument.removeObject(face.Name)
except Exception as err:
App.Console.PrintError("'recreate Object' Failed. "
"{err}\n".format(err=str(err)))
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(exc_type, fname, exc_tb.tb_lineno)
Note:
Unfortunately, Part.Show doesn't return the created object. Which is a big problem .. You cannot use it in python. How can you find the created object? it is impossible if you think general.
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
Re: Would you please let me know why it is wrong?
sorry, you see it became a long title.Shalmeneser wrote: ↑Thu Dec 02, 2021 5:35 pm Could you choose more specific title for your post, please ?
Design456 Direct Modeling. Coin3D GUI Toolkit. Objects get simplified.
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
https://github.com/MariwanJ/Design456 - https://wiki.freecadweb.org/Design456_Workbench
https://www.youtube.com/watch?v=6agcHPd ... utbTDH93m_
- Shalmeneser
- Veteran
- Posts: 9580
- Joined: Wed Dec 23, 2020 12:04 am
- Location: Fr
Re: Would you please let me know why it is wrong?
No problem. It will be better for memory and future research.