Library and Structure WB
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Re: Library and Structure WB
I have been reading and learning FreeCAD and I also have checked, not in deep, the flamingo workbench. As emills2 has mentioned, the CSW is a nice idea but has the problem of flexibility. Would be nice if the complete sketch from the profile is defined at the file and not only some geometrical parameters from a pre-defined sketch.
I have been cheking the difference between part and body in FreeCAD. I am still not 100% sure about the difference, any help will be appreciated. The best explanation that I have found is at the following discussion:
https://forum.freecadweb.org/viewtopic.php?f=9&t=15269
According the explanation from ickby, body is part of PartDesign workbench and the features from this WB can be used with Body. The Library WB should include solids with some standard geometrical dimesnions and after the users should be able to make cuts, holes, bend operations, etc. For this reason, I think that all standard parts should derive from body.
After a few work, I have define a propose of class structure on the Library WB. The diagram shows the object (classes) that I want to define at the library WB and the end structure of the standard components at the library. I will be very happy if the developers from the different WB propose their ideas and show interes on this Workbench.
To define the structure showed at the picture, I have use as base the Autodesk Inventor library structure and the spanish uBIM guide from the BuildingSMART web.
My next step is to learn a littel of C++ and analyze in deep the PartDesign Workbench to define tha classes. At my actual status, I think that the additive primitive comands from PardDesign WB are a good base to create the code of the libary WB. For the moment I think to use C++ for the WB and python for the sketches files, the equivalence of CSW at flamingo WB. if someone thinks that this is a good base to start a WB I would like that some poeple with knoleg on C++ and FreeCAD development helps.
I have been cheking the difference between part and body in FreeCAD. I am still not 100% sure about the difference, any help will be appreciated. The best explanation that I have found is at the following discussion:
https://forum.freecadweb.org/viewtopic.php?f=9&t=15269
According the explanation from ickby, body is part of PartDesign workbench and the features from this WB can be used with Body. The Library WB should include solids with some standard geometrical dimesnions and after the users should be able to make cuts, holes, bend operations, etc. For this reason, I think that all standard parts should derive from body.
After a few work, I have define a propose of class structure on the Library WB. The diagram shows the object (classes) that I want to define at the library WB and the end structure of the standard components at the library. I will be very happy if the developers from the different WB propose their ideas and show interes on this Workbench.
To define the structure showed at the picture, I have use as base the Autodesk Inventor library structure and the spanish uBIM guide from the BuildingSMART web.
My next step is to learn a littel of C++ and analyze in deep the PartDesign Workbench to define tha classes. At my actual status, I think that the additive primitive comands from PardDesign WB are a good base to create the code of the libary WB. For the moment I think to use C++ for the WB and python for the sketches files, the equivalence of CSW at flamingo WB. if someone thinks that this is a good base to start a WB I would like that some poeple with knoleg on C++ and FreeCAD development helps.
- Attachments
-
- LibraryParts.jpeg (197.34 KiB) Viewed 2034 times
Re: Library and Structure WB
Regarding the geenration of each body, actually i think that the library WB should allow the creation from python scripts or from the different CAd formats that are compatible with FreeCAD.
The step models do not save the properties from the original model, for this reason, at the case that the user wants to create a new standard component from a step model, the user should should combine the python scripts with step model. at this fistr propose, the step model will have the geometry and the python script will have the properties from the parts.
At the case that the users wants to use IFC files, the classes from the BIM or MEP family shoudl be defined accorfing the IFC standard to be able to create a body without any problem and withour lossing information. Bellow there is a picture about how should appear each standard part at the tree from FreeCAD. At the moment, I have not found any aditional WB that is working according the features from the version 0.17. If there is any I will apreciate the comment to check the code and try to use as a base.
The step models do not save the properties from the original model, for this reason, at the case that the user wants to create a new standard component from a step model, the user should should combine the python scripts with step model. at this fistr propose, the step model will have the geometry and the python script will have the properties from the parts.
At the case that the users wants to use IFC files, the classes from the BIM or MEP family shoudl be defined accorfing the IFC standard to be able to create a body without any problem and withour lossing information. Bellow there is a picture about how should appear each standard part at the tree from FreeCAD. At the moment, I have not found any aditional WB that is working according the features from the version 0.17. If there is any I will apreciate the comment to check the code and try to use as a base.
- Attachments
-
- CapturaFreeCAD.PNG (9.19 KiB) Viewed 2029 times
Re: Library and Structure WB
I am playing with FreeCAD to understand the code and be able to go forwards with my propose of WB. I still not have the knowlege to be able to start the workbench, I need to discover how can I create an object that derives from Part or Body. Can someone explain me how can I create a standard object class where the parent is the part or Body object? Does someone recomend a new class different to Part or Body tat also derive from BodyBase?
For the moment I have discover a way to get the end result mentioned at the previous post using python. I have created the encapsulate function to be used inside the scripted objects like all the primitive object to get them as a Part with the origin. Has someone a different idea about this issue to get the same ressult in a more efficient way?
For the moment I have discover a way to get the end result mentioned at the previous post using python. I have created the encapsulate function to be used inside the scripted objects like all the primitive object to get them as a Part with the origin. Has someone a different idea about this issue to get the same ressult in a more efficient way?
- Attachments
-
- EncapsulateObject.PNG (24.1 KiB) Viewed 1977 times
Re: Library and Structure WB
Hi,
I have made a few tests to continue with the evolution of the library workbench that I proposed. Actually I am able to make some test with the encapsulate function for round and rectangulars bars and tubes, with this function I am able to make the following:
Actually I am not making anything new, I only extract the code from fasteners and Arch Workbench and I write tehm on a diferent way. My actual intention is not to make something completly new, I only introduce the option of type of object that I create (Body, part, etc.). For other side, I also make a modular library of "standard parts"/ Scripted parts. For example, the power users cannot add or delate any new profile to arch WB making only a copy of one python file at one directory without taking care about the WB code, same issue at the fasteners WB. The new workbench will import all the python scripts that can be found at the library directory, the user will not need to change any line of code insisde any WB, he will only need to download the scripted file and copy it at the directory. The user that can write python will aslo be able to create a new standard part following some rules and without any modification of the WB code.
Finally I also have started to create the IDE for the library workebch. I have started to define the IDE following the standards from AutoDesk, I know solidworks but I am user from Inventor. You will find my progress at the picture attached bellow. My intention is to continue with the design according Inventor but prepare the software to have an end version where the user can decide at the preferences if they want something silimar to Inventor or if they prefer something similar to the actuar Arch WB.
If you have any comment, please do not be hesitate to post your ideas and comments.
I have made a few tests to continue with the evolution of the library workbench that I proposed. Actually I am able to make some test with the encapsulate function for round and rectangulars bars and tubes, with this function I am able to make the following:
- Python object
- Part: Python feature inside a part
- Body: Python feature that is introduced at a new body using the bolean operation
- Body inside part: Python feature that is introduced at a new body using the bolean operation, and this body is incuded at a part
Actually I am not making anything new, I only extract the code from fasteners and Arch Workbench and I write tehm on a diferent way. My actual intention is not to make something completly new, I only introduce the option of type of object that I create (Body, part, etc.). For other side, I also make a modular library of "standard parts"/ Scripted parts. For example, the power users cannot add or delate any new profile to arch WB making only a copy of one python file at one directory without taking care about the WB code, same issue at the fasteners WB. The new workbench will import all the python scripts that can be found at the library directory, the user will not need to change any line of code insisde any WB, he will only need to download the scripted file and copy it at the directory. The user that can write python will aslo be able to create a new standard part following some rules and without any modification of the WB code.
Finally I also have started to create the IDE for the library workebch. I have started to define the IDE following the standards from AutoDesk, I know solidworks but I am user from Inventor. You will find my progress at the picture attached bellow. My intention is to continue with the design according Inventor but prepare the software to have an end version where the user can decide at the preferences if they want something silimar to Inventor or if they prefer something similar to the actuar Arch WB.
If you have any comment, please do not be hesitate to post your ideas and comments.
- Attachments
-
- ISO 7092 test.PNG (31.27 KiB) Viewed 1930 times
-
- ISO_7092-test.py
- (4.18 KiB) Downloaded 58 times
Re: Library and Structure WB
Hi @fdomateu.
I don't have much time ATM to do any testing. But your approach sounds good and hopefully you will get some feedback from potential users soon.
I don't have much time ATM to do any testing. But your approach sounds good and hopefully you will get some feedback from potential users soon.
Re: Library and Structure WB
I agree, people are keeping an eye on this..there is also a lot going on the FC world right now with the influx of a lot of participation and community growth (this project included) but please don't despair if you aren't seeing much participation ATM). Keep going!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Library and Structure WB
Hello,
I have continue learning the FreeCAD code and I have make some texts. Until know I have been using the Part::Part and PartDesign::Body objects, I have also used the Part::FeaturePython object. During my texts I have seen that I can add properties dinamically to Part::FeaturePython but I have also find that I cannot dinamically add propeties to Part::Part and PartDesign::Body. On this way, I cannot add string properties as Norm, OldNorm, etc, to the standard part. I think that I nned to create a new FreeCAD object to create standard parts.
Can someone explain me how can I create a standardPart/standardBody Object that contains the following:
Thanks
I have continue learning the FreeCAD code and I have make some texts. Until know I have been using the Part::Part and PartDesign::Body objects, I have also used the Part::FeaturePython object. During my texts I have seen that I can add properties dinamically to Part::FeaturePython but I have also find that I cannot dinamically add propeties to Part::Part and PartDesign::Body. On this way, I cannot add string properties as Norm, OldNorm, etc, to the standard part. I think that I nned to create a new FreeCAD object to create standard parts.
Can someone explain me how can I create a standardPart/standardBody Object that contains the following:
- App::Origin object
- Primitive feature with the shape from the standard part choosed, it should be cretated as scripted object
- The substraction group compatible with PartDesign features to introduce the user necessary substraction operations
- The rest of properties that will have the standard parts/Bodies (Norm, OldNorm, Description, the dimensions from the primitve feature that should be editable, etc.)
Thanks
-
- Posts: 3
- Joined: Tue Jan 31, 2017 9:34 pm
Re: Library and Structure WB
Doing god's work fdomateu ! Keep it up! It is just what we mechanical engineers need! Looking forward to see it implemented. Step by step FreeCAD will become on par with most modern software!
Re: Library and Structure WB
fdomateu wrote: ↑Sat Jul 28, 2018 7:08 pm Can someone explain me how can I create a standardPart/standardBody Object that contains the following:
- App::Origin object
- Primitive feature with the shape from the standard part choosed, it should be cretated as scripted object
- The substraction group compatible with PartDesign features to introduce the user necessary substraction operations
I have check the code from Arch workbench and I have tried to make this using App::PropertyLink, App::PropertyLinkList and App::PropertyString without success. The problem that I get is that the FeaturePython object is not iterable. Can someone help me and explain me which type of object should I use?
- The rest of properties that will have the standard parts/Bodies (Norm, OldNorm, Description, the dimensions from the primitve feature that should be editable, etc.)
@yorik any idea ?yorik wrote:ping
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Library and Structure WB
Here an example to extend a box or a sphere
If you change the dimA property of the extend the basic objects are updated too.
If you change the dimA property of the extend the basic objects are updated too.
Code: Select all
import random
##\cond
class FeaturePython:
''' basic defs'''
def __init__(self, obj):
obj.Proxy = self
self.Object = obj
obj.addProperty("App::PropertyBool","_noExecute",'zzz')
obj.addProperty("App::PropertyBool","_debug",'zzz')
def attach(self, vobj):
self.Object = vobj.Object
def __getstate__(self):
return None
def __setstate__(self, state):
return None
class ViewProvider:
''' basic defs '''
def __init__(self, obj):
obj.Proxy = self
self.Object = obj
def __getstate__(self):
return None
def __setstate__(self, state):
return None
##\endcond
def execute(self,obj):
self.obj2=obj
if self.obj2.ViewObject.Visibility == False:
return
try:
if self.Changed:
# ignore self changes
self.Changed=False
return
except:
pass
class Extender(FeaturePython):
def __init__(self, obj):
FeaturePython.__init__(self, obj)
obj.addProperty("App::PropertyLink","Source")
obj.addProperty("App::PropertyFloat","dimA").dimA=30
obj.addProperty("App::PropertyFloat","dimB")
obj.addProperty("App::PropertyFloat","dimC")
def execute(self,fp):
# avoid recursive calling with the lock trick
print "EXECUTE"
try: self.Lock
except: self.Lock=False
if not self.Lock:
self.Lock=True
try:
print "run myexecute"
self.myexecute(fp)
pass
except:
print "problems with myexecute"
self.Lock=False
else:
print "no myexecute"
def onChanged(self,fp,prop):
self.myupdate(fp)
fp.Source.purgeTouched()
def myupdate(self,fp):
print ("update the core object",fp.Source.Label)
try:
print fp.Source.Length
fp.Source.Length=fp.dimA
except:
print "cannot set Lenght"
try:
print fp.Source.Radius
fp.Source.Radius=fp.dimA
except:
print "cannot set Radius"
def myexecute(self,fp):
fp.Shape=fp.Source.Shape
fp.Source.purgeTouched()
def createExtender(sels=None):
if sels==None:
sels=Gui.Selection.getSelection()
for fa in sels:
sf=App.ActiveDocument.addObject('Part::FeaturePython','Extend')
sf.ViewObject.ShapeColor=(0.5+random.random(),random.random(),random.random(),)
Extender(sf)
ViewProvider(sf.ViewObject)
sf.Source=fa
sf.Label="Extend for " + fa.Label
App.activeDocument().recompute()
sf.Proxy.execute(sf)
box=App.ActiveDocument.addObject("Part::Box","Box")
sphere=App.ActiveDocument.addObject("Part::Sphere","Sphere")
createExtender([box,sphere])
box.Placement.Base.z=100
sphere.Placement.Base.z=-100