API request: create entities from transients
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When working with modeling scripts, you might want to use a lot of transients to get things done. Eventually, you will want to convert them into curves or construction planes, or whatever the transient represents.
For example, I can create Arc3D which has a nicer createByCenter than sketchArcs.createByCenterStartSweep.
I had to come up with wrapper functions like so:
def projectToSketch(self, sketch, recompute=False):
sCurves = sketch.sketchCurves
planeNormal = sketch.referencePlane.geometry.normal
sArcs = sCurves.sketchArcs
projected = []
for arc in self.arcs(recompute=recompute):
# project into sketch coordinates the points given in world coordinates
cp = sketch.modelToSketchSpace(arc.center) # center point
sp = sketch.modelToSketchSpace(arc.startPoint) # start point
normalAngle = planeNormal.angleTo(arc.normal)
angle = arc.endAngle - arc.startAngle
angle = -angle if normalAngle>0 else angle
sarc = sArcs.addByCenterStartSweep(cp, sp, angle)That's a pain in the neck. You need to add a lot more computation into the script you are writing. Also, as a suggestion, when you create sketch entities from transients, it would bring the points to sketch plane so I don't need to convert every single point.
Another example: Circle3D. It has a nice option to set the normal vector which is perfect to my application. Otherwise, I have two options: to create a new sketch that has the same normal, create circle; second is to create circle, and then move applying transform matrix to follow the same normal.
Transient objects are awesome. Thanks for having them. But please take them to next level!