cancel
Showing results for 
Search instead for 
Did you mean: 

recursive cube generator with scale builder

Genius
Genius

I'm trying to create a recursive cube generator using the scalebuilder class. It almost works the way I intended except I'm having an issue with the scalebuilder.uniformfactor attribute. Everytime I run the loop, it exponentiates. How could I make it immutable? See attached picture

 

https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_pyt...

 

    def recursivecubes(self, bodiez, endlist):
        global bodylist, scaleendpoint, scalebuilder, scalefactor
        scaleendpoint = []
        bodylist = []

        #find object
        for body in bodiez:
            #append to list so that way we are not scaling every cube body just the first cube
            bodylist.append(body)
            self.theLw.WriteLine("    Journal Identifier: " + str(body.JournalIdentifier))


        scalefactor=.33333333333

        #iterating over the list of endpoints
        for i in range(len(endlist)):

            #call the scalebuilder method
            scaleBuilder = workPart.Features.CreateScaleBuilder(NXOpen.Features.Feature.Null)

            #scale the first cube, we don't want to scale each newly created cube
            scaleBuilder.BodyToScale.Add(bodylist[0])
            #list of end points
            scaleendpoint.append(workPart.Points.CreatePoint(endlist[i]))

            #where to place each scaled cube
            scaleBuilder.Point = scaleendpoint[i]

            #refer to expression attributes https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/nxopen_python_ref/NXOpen.Expression.html#NXOpen.Expression
            #herein lies the issue, this attribute exponentiates for every iteration
scaleBuilder.UniformFactor.Value=scalefactor #create the cube scaleBuilder.Commit()

#these properties should lock the variable but they don't work
#scaleBuilder.UniformFactor.IsNoEdit= True
#scaleBuilder.UniformFactor.IsNoUpdate= True

#resetting the uniformfactor does not work
#scaleBuilder.UniformFactor.Value=None

#always need to call this scaleBuilder.Destroy()

 

1 REPLY

Re: recursive cube generator with scale builder

Genius
Genius

almost works the way I intended