I would like to copy a feature within a body. Specifically, I have a threaded hole that I would like to copy several times and then adjust the tolerances on each of the copies - so the copy shouldn't affect the original. I have tried copy+paste, but the results of the paste don't appear in the original body.
Manually duplicating each hole, by creating another sketch and then creating a hole from that and manually re-entering all the hole parameters is tedious.
OS: macOS 10.16
Word size of FreeCAD: 64-bit
Version: 0.20.27078 (Git)
Build type: Release
Python version: 3.9.9
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: C/Default (C)
How do I copy a feature?
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: How do I copy a feature?
I was not successful with my various tries to do this (copy feature+sketch, move into body, copy whole body+move feature+sketch,...) so I doubt that this is possible without help of Python.
Anyway, it would make a reasonable feature request to use a feature as a template!
Anyway, it would make a reasonable feature request to use a feature as a template!
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: How do I copy a feature?
I finally found a way, but it is a bit tricky:
- Select feature+Sketch and copy just these two
- paste; this places both outside of the body.
- drag the sketch into the body
(dragging the feature doesn't work, it creates a basefeature)
- select the body
- edit its group property, use the button occurring at the right
(- you are not finished yet, now you have either the previous or the last feature)
- select the new feature
- in the context menu of the property panel select Show All
- change the BaseFeature to the desired predecessor using the three dots button appearing at the right
- Select feature+Sketch and copy just these two
- paste; this places both outside of the body.
- drag the sketch into the body
(dragging the feature doesn't work, it creates a basefeature)
- select the body
- edit its group property, use the button occurring at the right
(- you are not finished yet, now you have either the previous or the last feature)
- select the new feature
- in the context menu of the property panel select Show All
- change the BaseFeature to the desired predecessor using the three dots button appearing at the right
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: How do I copy a feature?
I'm going to ping @TheMarkster, because I think the Part Design wrapper that he invented can do this, but, I'm not familiar enough with it to instruct how.
https://wiki.freecadweb.org/Macro_PDWrapper
https://github.com/mwganson/pdwrapper
TheMarkster wrote: ping
https://wiki.freecadweb.org/Macro_PDWrapper
https://github.com/mwganson/pdwrapper
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: How do I copy a feature?
With last version of Fastener WB you can add "threaded rod" (only with threaded rod not with other screws...) with custom parameters :
You can use this threads with boolean operations in Part Design for create holes.
(I had to uninstall and reinstall fasteners WB to get the latest version which includes this feature.)
You can use this threads with boolean operations in Part Design for create holes.
(I had to uninstall and reinstall fasteners WB to get the latest version which includes this feature.)
- Attachments
-
- Capture d’écran (98).png (11.49 KiB) Viewed 567 times
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: How do I copy a feature?
I don't think PDWrapper is the tool for this task, at least not as I understand it. OP wants several duplicates of a Hole and to be able to modify the properties of each duplicate individually, but to have all the original Hole's properties in each as a starting point.
You could make all the holes, each from a separate sketch (or each from a green subshapebinder, each linking to a different circle from the same sketch), and then use some python scripting to copy the properties from the first Hole to all the others.
Code: Select all
orig = App.ActiveDocument.getObject("Hole")
dups = [obj for obj in App.ActiveDocument.Objects if "Hole" in obj.Name and obj != orig]
for prop in orig.PropertiesList:
if prop == "Profile" or prop == "BaseFeature" or prop == "Shape" or prop == "AddSubShape" or prop == "ExpressionEngine":
continue
for dup in dups:
try:
setattr(dup,prop,getattr(orig,prop))
except:
App.Console.PrintError(f"Error setting {prop}, trying as expression...\n")
dup.setExpression(prop,orig.Name+"."+prop)
- Attachments
-
- holes_before.FCStd
- (59.65 KiB) Downloaded 9 times
-
- holes_after.FCStd
- (53.43 KiB) Downloaded 11 times