cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

PRINT Command...

Anonymous
Not applicable
Is there a good place to write the PRINT command to make it works with a string?

PRINT "Error, check the value"

do nothing...
The manual writes that it should appear a dialog with my "string"....

Thank you in advance.

Regards

PWD
20 REPLIES 20
Anonymous
Not applicable
IMHO the only time to use print is for validation when scripting. For example:

!------> Master Script <-----!
lenSTR = STR("%.16ffi", A)

!------> 2D Script <-----!
PRINT lenSTR

When you click on the "2D Full View button", the print command will show the string, in this case the value of A in feet inches and 1/16th's.

And yes, users get pretty annoyed if you forget to remove your print commands.
Anonymous
Not applicable
!------> Master Script <-----!
lenSTR = STR("%.16ffi", A)

!------> 2D Script <-----!
PRINT lenSTR
And if I do not use the Master Script?

For Example:

!----->2D Script<-------!

nscrew=10

PRINT nscrew

[END]


Does it works for you? Not for me.

Thanks
PWD wrote:
And if I do not use the Master Script?Does it works for you? Not for me.
Thanks
You dont need to use the print command for a finished object, and as Sean said, its still incredibly useful for validating things. but you need to use it in the 2D or 3D scripts for you to see the result, thats true. if you calculate the number of screws you need (and heaven knows, we could all do with more than we get!) then do the calculation in the master script, but place the print command in either 2d or 3D.
develop some good error catching routines, and also make more use of the parameters command to repair the user's errors.
Anonymous
Not applicable
Like David I haven't used the PRINT statement in years. For debugging I use TEXT2 statements to print values in the 2D full view. This is particularly useful for parts that respond to values that are not testable in the libray part editor (such as SYMB_ROTANGLE or GLOB_CONTEXT). The text in the symbol allows you to place multiple intances in plan and rotate, multiply, stretch, etc. to make sure they work in all situations.

(Naturally, I remove or comment the TEXT2 statements once the testing is done.)
Anonymous
Not applicable
I've had problems using the PRINT command in some instances and have yet to figure out why so using the TEXT2 command for error checking sounds like a great idea. I dont know why I never thought of it since we use it some of our objects. If you stretch an object beyond a max length, the pen changes to 10 and an error message is printed in plan view.

In this instance though you would have to convert the value for nscrew to a text string.

nscrew = 10
TEXT2 x ,y, STR (nscrew, 8, 0)
Anonymous
Not applicable
Sean wrote:
If you stretch an object beyond a max length, the pen changes to 10 and an error message is printed in plan view.
You should try David's advice and limit the upper value of the parameter. Such as:

IF length_n > 10 THEN
length_n = 10
PARAMETERS length_ n = length_n
ENDIF

This will prevent the symbol from exceeding the maximum length and reset the value displayed in the dialog.

It is always better to do error checking and correction automatically than bugging the user with error massages. I am especially annoyed by library parts that simply display the words "INVALID PARAMETERS"leaving the user to try to figure out why something isn't working with useful information to go on. The coding is typically easier (since you are preventing non-working values) and the finished parts are much more user friendly.
Anonymous
Not applicable
I dont do it that way because forcing a value via the PARAMETERS command removes the stretchy properties. The user has to manually change the value to something less than the max to get the stretchy feature back.

It's an inconvenience either way.
Anonymous
Not applicable
Sean wrote:
I dont do it that way because forcing a value via the PARAMETERS command removes the stretchy properties. The user has to manually change the value to something less than the max to get the stretchy feature back.

It's an inconvenience either way.
The stretchiness is easily retained. I am not sure what you are doing to defeat it. You might like to try one of the following:

1. This is similar to my previous post except that I am just using the default "A" (horizontal size) parameter. This approach has the drawback that the part appears to stretch beyond the limit and then snaps to the new point stretched to and moves the origin point over to conform to the maximum value (I suppose this might even be useful in certain circumstances).

In the Master script:

IF A > 10 THEN PARAMETERS A = 10

In the 2D script:

RECT2 0, 0, A, B

2. This method seems to have no drawbacks and works smoothly and precisely as one would expect. The part simply will not stretch beyond the maximum.

In the Master script:

VALUES `a` RANGE [0, 10]

In the 2D script: (same as above)

RECT2 0, 0, A, B


In both cases the stretchiness is retained but the second method is clearly superior in most situations. The RANGE function also works to set a lower limit (0 as shown above). Modified as shown below, the code limits the user to stretch horizontally between 9 and 10 meters.

VALUES `A` 9, RANGE [9, 10]

Adding the STEP function (below) allows you to limit the user to specific increments within the RANGE. This snaps to the allowed values as the user stretches the library part.

VALUES `A` RANGE [5, 10] STEP 5, 0.5

As far as I can tell there is no limit to defining multiple ranges and step values for a given parameter. The added RANGE statement below allows values between 5 and 10 meters and between 15 and 20 meters. In use the symbol snaps smoothly to all allowed values.

VALUES `A` RANGE [5, 10] STEP 5, 0.5, RANGE [15, 20] STEP 15, 0.33

All in all, this is very cool stuf which I have onkly just barely begun to exploit. GDL keeps getting more powerful and easier all the time. (Except that there is so much more to do now to take advantage of all the cool new capabilities )
Matthew wrote:
You should try David's advice and limit the upper value of the parameter. Such as:

IF length_n > 10 THEN
length_n = 10
PARAMETERS length_ n = length_n
ENDIF

This will prevent the symbol from exceeding the maximum length and reset the value displayed in the dialog.
I agree with you completely, matthew, and am not sure why Seans objects dont stretch, all my objects stretch, but I use the methods on Mathews later message to limit them, eg RANGE in the VALUES list.

On thing that is a must though, if Matthew will allow me to correct him in public is that the "greater than or equals" is more reliable, otherwise for some reason, some things might stick at one length and not stretch, ie you should write:
IF length_n >= 10 THEN
length_n = 10
PARAMETERS length_ n = length_n
ENDIF

some people say that you can shorten this to 1 line:

IF length_n >= 10 THEN PARAMETERS length_ n = length_n

But I find this unreliable too, and the method aforementioned is the more reliable solution (and is DNC+GS recommended), and only requires a tiny amount extra typing.
Anonymous
Not applicable
david wrote:
On thing that is a must though, if Matthew will allow me to correct him in public is that the "greater than or equals" is more reliable, otherwise for some reason, some things might stick at one length and not stretch..
David,

You caught me being sloppy in my example. I always use the "greater than or equal to" (>=) in my actual coding. When I need "greater than" or "less than" I use something like:

IF x >= 0.0001 THEN...

I am glad you spotted this. I would hate to inadvertantly lead people into flaky coding.