Jump to content

Recommended Posts

Hi,

 

This is a post in the context of project performance:

 

If you use loops with feature definitions, take care where you declare ("create") your participating objects:

 

Most of the times, objects can be declared outside of the loop since the dependency is kept within the loop by means of the expression mechanism!

 

In the attached example, I create N curves in between of two given rail curves and store them in a list for surface creation. The two points on the corresponding rails are declared right before the loop starts. You could also declare them within the loop but - and here comes the message - they would be created again and again, i.e. at each iteration (N-times). In the end, this might slow down your feature execution when it comes to a higher number of objects that get declared within a loop.

 

Hope this helps ...

 

Cheers

Joerg

post-8-0-93429700-1386857257_thumb.png

loop.fdb

Share this post


Link to post
Share on other sites

Hi all,

 

I've tried this loop functionality with a generic function but although I get no error message in the attached feature I cannot get the curves to be plotted in caeses.

 

My goal is the plot a number of radial 2d section-lines of a developed blade.

 

BR

Daniel

R_def.fdfc

Share this post


Link to post
Share on other sites

Hey Daniel,

 

I've had a look into your feature definition and I changed some minor but important things.

 

You need to create the parameters inside the loop that they are updated every time.

 

The feature creates the curves. I tested the feature with the propeller sample.

Here you can see the result. post-41-0-85899900-1390936092_thumb.png

 

Best Regards

 

Karsten

R_Def_FS.fdf

Share this post


Link to post
Share on other sites
Guest Mr. Olivier Duquette

Hi,

I tried to declare a curve outside a loop and then give it a "value", like this:


fcurve camber()


loop (5)
     camber= camber_i.at(j-1).castTo(fcurve)     // camber_i   is an objectlist containing 5 curves.

     [...]   

endloop

But I am getting an error message: No operator = defined for types: FCurve and FCurve

So I did it this way:

loop (5)
     fcurve camber(camber_i.at(j-1).castTo(fcurve))    // camber_i   is an objectlist containing 5 curves.

     [...]   

endloop


So my question is: do I have to declare the curve inside the loop, or there is a way to do what I was trying in the first example?

Thank you,

Olivier Duquette
 

Share this post


Link to post
Share on other sites

Hi Oliver,

 

since the Feature Language doesn't have the concept of scoping known from C or Java (or others). So, in short, it doesn't really matter whether you declare the FCurve reference "camber" inside or outside the loop. These two are equivalent:

bsplinecurve myCurve()
FCurve myReference()

loop(1)
  FCurve myReference(myCurve)
endloop

// The reference is still valid here, so I can do the following, for example:
myReference.getPos(0.5)
// which is equivalent to calling ".getPos(0.5)" on "myCurve"

and

bsplinecurve myCurve()

loop(1)
 FCurve myReference(myCurve)
endloop

// The reference is still valid here, so I can do the following, for example:
myReference.getPos(0.5)
// which is equivalent to calling ".getPos(0.5)" on "myCurve"

Note that most types in the Feature Language do not have assignment operators ("=").

 

Also note that the Syntax "FCurve something([...])" creates a reference to an existing curve. it does not create a new curve! Also see the documentation of FFeatureDefinition for more information about references.

 

Be aware that in your example, the "camber" reference will reference the last (fifth) curve in your objectlist after the loop. Inside the loop it will reference different curves for each run of the loop.

 

Finally, while my initial statement regarding variable scoping is true, there is one little exception: variables that are declared inside a function are only valid within the function.

 

I hope this helps.

 

Arne

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...