An Open Source parametric 3D CAD modeler (Thanks to Jay Bowden)
Sometimes an object made by combining circles may not have the parts connected. Select the points on each circle which should be coincident and then press the single dot icon.
sel=Gui.Selection.getSelectionEx() for i in sel: for j in i.SubElementNames: print "Area of ",j,": ", getattr(i.Object.Shape,j).AreaFYI, getSelectionEx() returns a list of selection objects. A selection object keeps a reference to the actual object and the sub-elements. However, the sub-elements list is empty if the complete object was selected e.g. over the tree view.
The above code snippet iterates over the list of selection objects and inside it over the selected sub-elements. The sub-elements are strings and are exactly the names you wanted. So, with getattr() we access the shape data of the object and query its sub-element. The returned object of getattr() is then the face object and we can then directly access its Area attribute.
If you have a Object called "Box" in your document (no matter how it's created, in console or by scripting) you can access it by its name. Try it in the python console, the class browser will show your objects as part of the active document. That technique can be used to select the object too.App.ActiveDocument.Box #Access document object named "Box" Gui.Selection.addSelection(App.ActiveDocument.Box) #select document object named "Box"To get the Volume of a part the document object is not enough, you need to retrieve the geometrical shape. This shape has a property to access its volume (again, use the class browser to search what else is in that shape, pretty cool stuff)
App.ActiveDocument.Box.Shape.Volume
Macro to let a SCALED SPHERE cut a BOX:
# Macro Begin: C:\Users\jay4pcb\Documents\newegg.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++import FreeCAD import Part import Draft #Gui.activateWorkbench("PartWorkbench") App.ActiveDocument.addObject("Part::Sphere","Sphere") App.ActiveDocument.recompute() #Gui.SendMsgToActiveView("ViewFit") #Gui.activateWorkbench("DraftWorkbench") Draft.scale([FreeCAD.ActiveDocument.Sphere],delta=FreeCAD.Vector(1.0,1.0,1.0),center=FreeCAD.Vector(0,0,0),copy=False) FreeCAD.getDocument("Unnamed").getObject("Scale").Scale = (1.00, 0.10, 0.10) #Gui.activateWorkbench("PartWorkbench") #App.setActiveDocument("Unnamed1") #App.ActiveDocument=App.getDocument("Unnamed1") #Gui.ActiveDocument=Gui.getDocument("Unnamed1") App.ActiveDocument.addObject("Part::Box","Box") App.ActiveDocument.recompute() # Macro End: C:\Users\jay4pcb\Documents\newegg.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
How to change obj properties Objects are added in order of creation to FreeCAD.ActiveDocument.Objects. So you can always get the last created object with: FreeCAD.ActiveDocument.Objects
Create simple part vs. Create clone^ arcol wrote:I just figured, if I check the "Copy" checkbox while using Move tool from Draft workbench, it also creates some kind of a copy. Is it identical to Part->Create simple copy command? (the copied part gets a small blue cube icon) Yes, it's a simple part. no parametric properties or linkage.
TopoShape: The TopoShape is the mother object of the Part Module. All shape types (wire, face, solid, etc...) of the Part module are TopoShapes, and share the following attributes and methods. Example:
import Part sh = Part.makeBox(10,10,10) print sh.Faces for f in sh.Faces: print f.Edges
Hint: Measuring Parts. FreeCAD has a measurement tool accessible from the View menu or the toolbar. You can also assign it to something like ctrl-M (see Tools/Customize/Keyboard). You basically have to select two points and it will add the measurement. The length is best seen in the Tree View (as it is notorious to be placed far away from the geometry). It can also be deleted from there.
Hint: Better Visualization of Object Coordinates. "View > Toggle Axis Cross" to show the origin, and thereby make sense of the position co-ordinates for each object.
Hint: Coordinates are listed in ZXY order not in XYZ order. H=z, L=x, W=y, X,y,z = L,W,H
See also:
Scaling all the lines, arcs, etc. in a group with the Draft, Scale tool leaves a single, un-editable clone.
file: /Techref/app/freecad.htm, 6KB, , updated: 2016/7/27 08:44, local time: 2024/12/17 20:30,
18.225.57.198:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/app/freecad.htm"> FreeCAD CAD Application</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.