How to move rectangle along axis using two handles

Balises:

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/

Pièces-jointes (2)

Type: image/jpeg
Téléchargé 376 fois
Size: 95,33 KiB
Type: application/octet-stream
Téléchargé 1427 fois
Size: 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

Pièces-jointes (3)

Type: image/png
Téléchargé 321 fois
Size: 68,38 KiB
Type: image/png
Téléchargé 430 fois
Size: 56,35 KiB
Type: application/octet-stream
Téléchargé 1497 fois
Size: 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/

Pièces-jointes (1)

Type: application/octet-stream
Téléchargé 1252 fois
Size: 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

Pièces-jointes (2)

Type: image/png
Téléchargé 365 fois
Size: 20,29 KiB
Type: application/octet-stream
Téléchargé 1375 fois
Size: 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/

Pièces-jointes (2)

Type: application/octet-stream
Téléchargé 1561 fois
Size: 7,41 KiB
Type: application/octet-stream
Téléchargé 1561 fois
Size: 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

Pièces-jointes (1)

Type: image/png
Téléchargé 400 fois
Size: 8,36 KiB

https://campus.allplan.com/ utilise des cookies  -  Plus d'informations

Accepter