API request: create entities from transients

API request: create entities from transients

gscotti
Enthusiast Enthusiast
465 Views
0 Replies
Message 1 of 1

API request: create entities from transients

gscotti
Enthusiast
Enthusiast

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!

466 Views
0 Replies
Replies (0)