We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Help with another script

Anonymous
Not applicable
Having solved my previous problem with the help of fellow ArchiCad-talkers you will doubtless feel a sinking feeling that I have now moved to another object!

I attach an image of a little parametric knee brace on which I am working.

The pic shows just two possible orientations of the brace. The first location of the brace is indicated in red, whilst a second location of the brace is shown the the lines. The long sides of the brace are always parallel.

I want the user to be able to adjust the position of the brace by using two moving hotspots, one indicated in the pic by a cross, the other by a dot.

The 'dot' hotspot can move along the sloping part only, whereas the 'cross' hotspot can move vertically when in the orientation shown in red, and horizontally when the brace is in the orientation shown by lines.

I am stuck on how to constrain the movement of the 'cross' hotspot according to its location, and I do not want to pre-define the locations of the two hotspots i.e they can both be positioned (almost) anywhere along the constraints.

Any one out there got any suggestions, please?

Bracket.jpg
7 REPLIES 7
Anonymous
Not applicable
There might be some clever things that you could do with conditional (IF/THEN) statements, but it would be tricky (and perhaps not possible).

The easiest approach might be to ask the user to choose, with a simple check box, which part to constrain to.
Anonymous
Not applicable
Matthew

Thanks for the suggestion that I might include an option for the user to select but I rejected that some time ago. The main raeson is that the toggle is likely to be a) difficult to describe, and b) is likely to occupy more space that is visible in the object dialog window!

I go to some lengths to ensure that all the descriptions of parameters are brief and don't frustratingly disappear from view. I could, I suppose, add a text parameter with a range of values to serve as instructions, but I would prefer not to do that, but if all else fails...

Mike
Durval
Enthusiast
Instead of a boolean choice, you could initially make the 'cross' hotspot placeable anywhere, and then the script forces it to snap to either the vertical or horizontal beams, based on its proximity.
Something like
IF dist_from_X < dist_from_Y THEN dist_from_X=0 
IF dist_from_Y <= dist_from_X THEN dist_from_Y=0 
--- www.dtabach.com.br ---
AC 24 BR – MacBook Pro 2,9 GHz Intel Core i7 16GB RAM Mac OS 10.14
Frank Beister
Moderator
If you use if...then to check the plausability of the values you will loose the moveable hotspot, if the value is realy out of range.

Have you tried to use the RANGE command in combination with the VALUES format.

e.g.
values "coordX" RANGE (0.12,maxCoordX)
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
Thanks for the two suggestions - bit bogged down at the moment, but hope to look at these this weekend.

Many thanks, your help is appreciated!

Mike
Anonymous
Not applicable
I tried the suggestion from Durval. I couldn't get this to work properly in the Master or Parameters script without a PARAMETERS or VALUES statement for the location of the hotspot/cross. Then, as rightly pointed out by F. Beister, I would need a VALUES RANGE statement to control the values of x and y. (Because the dist_from_x and dist_from_y are used in a moving hotspot, dist_from_x and dist_from_y must be declared parameters, not just variables, so the expressions are now:

IF dist_from_X < dist_from_Y THEN PARAMETERS dist_from_X=0
IF dist_from_Y <= dist_from_X THEN PARAMETERS dist_from_Y=0)

Unfortunately I found that adding the VALUES RANGE statement prevented the constarints from working correctly!

Then...

I realised that the diagram I posted here previously was slightly wrong. The cross on the brace shown by lines should be on the other line -not the one shown.

The reason for this that I would prefer that the definition of the distance to the cross (measured from the intersection of the vertical and horizontal members, respectively) should always be measured from the same point to the same side - or, in other words, I want the cross to always be on the side of the brace closest to the 'origin'.

As things stand I can get this to work, without limits to the values of x and y (which is a nuisance), and there is currently no half-way.

By no half-way I mean that the the hotspot x is always effectively positive on x or y, whereas, in order to effect the transition there ought to be some allowance (negative') so that part of the 'x-marks-the-spot-end' of the brace is on the vertical axis and part lies along the y axis.

I tried modifying Durval's parameters to allow for this transitional condition, but got some very weird reuslts. It was v. late at night and perhaps I was not at my best, so I will try again, unless you guys out there have any bright ideas?

Mike
rocorona
Booster
My English is not so good, so I'm not sure if this is the solution for your problem, and if it is complete, but here is my "guess"...

Create the parameters 'x' and 'y' for the cross-node position (in fact the distance from the corner)

! ----- MASTER SCRIPT
VALUES "x" RANGE [0,a]
VALUES "y" RANGE [0,b]

IF x<>0 AND y<>0 THEN
IF ABS(x)>ABS(y) THEN PARAMETERS y=0 ELSE PARAMETERS x=0
ENDIF

! ----- 2D SCRIPT
LINE2 0,0, a,0
LINE2 0,0, 0,-b
LINE2 a,0, 0,-b

HOTSPOT2 a,-b

hid=hid+1: HOTSPOT2 0,-y, hid, x, 1
hid=hid+1: HOTSPOT2 x,-y, hid, x, 2
hid=hid+1: HOTSPOT2 -1,-y, hid, x, 3

hid=hid+1: HOTSPOT2 x,0, hid, y, 1
hid=hid+1: HOTSPOT2 x,-y, hid, y, 2
hid=hid+1: HOTSPOT2 x,1, hid, y, 3

!!!!!!!!!!!!!!!!!!!!!

___________________________________
--Roberto Corona--
_________________

--Roberto Corona--
www.archiradar.com
AC18 - ITA full on Win10
_________________
_________________