Support Forum

How to move rectangle along axis using two handles

Schlagworte:
  • 2012

Hi,

I'm creating a smartpart that move one rectangle along one axis. The difficult isn't create the rectangle with one handle move, the difficult is to create two move handles located on two corners, and fixing the rectangle dimensions.

In my smartpart, I write the script correctly, and the first "move handle" works well, but the second "move handle" don't move the rectangle. What's wrong?

Thanks a lot!
Xavi.

Xavier Coll • Architect, Project Manager I+D, BIM Manager, BIM Auditor
EiPM • http://www.eipm.es/en/

Anhänge (2)

Typ: image/jpeg
378-mal heruntergeladen
Größe: 95,33 KiB
Typ: application/octet-stream
1638-mal heruntergeladen
Größe: 5,92 KiB

Hi Xavi,

look at your Code:

id = id + 1
HANDLE2 0 , 0 , id , a , 1
HANDLE2 a , 0 , id , a , 2
HANDLE2 -10 , 0 , id , a , 3

id = id + 1
HANDLE2 REF_X , 0 , id , c , 1
HANDLE2 a + b , 0 , id , c , 2
HANDLE2 10 , 0 , id , c , 3

TRANS2 a , 0

COLOR 1
RECT2 0 , 0 , b , REF_Y
RESTORE 1

You modify the parameter "c" with a handle, but you don't use "c" anywhere !
Only parameter "a" is responsible for translation!
The problem is, that Parameter "a" and "c" are dependent from each other.
If you increase "c", "a" is decreased!
This dependency you can reflect with a short code in Parameter-Script:

IF GLOB_MODPAR_NAME = "c" THEN
a = REF_X - c - b
PARAMETERS a = a
ENDIF

I have added some limits, so that the black box cannot leave the cyan border :-)

Regards.
Jörg

Anhänge (3)

Typ: image/png
322-mal heruntergeladen
Größe: 68,38 KiB
Typ: image/png
430-mal heruntergeladen
Größe: 56,35 KiB
Typ: application/octet-stream
1709-mal heruntergeladen
Größe: 7,71 KiB

Ouuuups! you're absolutely right!

Very, very interesting trick of the command GLOB_MODPAR_NAME, and very usefull :-D

Thanks a lot for your fast answer, Jörg :-)
Regards,
Xavi

Xavier Coll • Architect, Project Manager I+D, BIM Manager, BIM Auditor
EiPM • http://www.eipm.es/en/

Jörg, I have another question about this Smartpart: Now I'm testing this smarpart and slowdown in the preview-mode/realtime modification when I assign layers to the rectangles.

Mmmm... I'm not sure what's wrong.

Thanks a lot!
Xavi

Xavier Coll • Architect, Project Manager I+D, BIM Manager, BIM Auditor
EiPM • http://www.eipm.es/en/

Anhänge (1)

Typ: application/octet-stream
1470-mal heruntergeladen
Größe: 6,25 KiB

Hi Xavi,

at my project the preview of your SmartPart isn't slow!
Can it be, that you have more (ton's of) layers in your project?
If you assign layer with short name:
LAYER "G27"
during the execution of the script
ALL layers have to searched after the layer with this short name!
Depending on amount of layers in the project, it can take a while!
Other thing is, that the short name "KO_ACHS" can have another (localized) name
on German installation of Allplan!

Better is the following:
1. Create parameter "ly" with type "Layer" an initial value of 3700
2. assign layer with LAYER ly
If you do so, the parameter creates an input combo box for selecting layer (s. layer_combo.png)
The advantage is, that the search is only done, if you change the layer!

Another possibility is, to assign the layer with the ID:
LAYER 3700
Then no search is necessary!

This is only possible, if you know the layer-ID and it should be Fix
and not changeable through the user.

Regards.
Jörg

Anhänge (2)

Typ: image/png
367-mal heruntergeladen
Größe: 20,29 KiB
Typ: application/octet-stream
1597-mal heruntergeladen
Größe: 9,02 KiB

Hi Jörg,

In our office, we use a powerful layer structure and it's a bit long. You're allright, the slow problem of the preview is because of the layers. ;-D

The third solution has been perfect! now goes fast :-)

I will add some complexity: I'm testing the same smartpart, but now I add an other rectangle. The black rectangle works well, but the red rectangle don't move correctly (is the new added rectangle).

I found a possible solution to solve this, but I don't know if is the right solution.

I send the two smartparts:
- the first with the red retangle problem
- the second, with the possible solution, but I'm not sure if is the correct solution.

Thanks a lot!
Xavi

Xavier Coll • Architect, Project Manager I+D, BIM Manager, BIM Auditor
EiPM • http://www.eipm.es/en/

Anhänge (2)

Typ: application/octet-stream
1762-mal heruntergeladen
Größe: 7,41 KiB
Typ: application/octet-stream
1776-mal heruntergeladen
Größe: 8,29 KiB

Hi Xavi,

your solution seems to work!

The problem is, that you have 2 handles refering the parameter "c"!
Additional the 2 handles need to modify different other parameters "a" and "e" !
So you have to identify the dragged handle, to modify the right dependent parameter.

Regards.
Jörg

Anhänge (1)

Typ: image/png
400-mal heruntergeladen
Größe: 8,36 KiB