Jump to content
Developer Wiki and Function Reference Links ×

First time programmer question


Recommended Posts

I have attempted to research this topic via Google to no avail as I do not know exactly what I am looking for.

I am trying to develop a custom dialog box that will allow a user to input numbers in order to create specific drawing.

The drawing itself is rather uncomplicated. It is a rectangle with an offset that will have a circles at intervals of 24" which is contingent on the rectangle dimension.

Similar to this image:

azXEtw9.png

This is the custom dialog box code I have manipulated.

PROCEDURE CreateDialog;
VAR
id: LONGINT;
result : LONGINT;
BEGIN
id := CreateLayout('Panel',TRUE,'Generate', '');

CreateGroupBox(id,4,'Shell',TRUE);
CreateEditText(id,5,'Width',26);
CreateEditText(id,6,'Length',26);

CreateGroupBox(id,7,'Armature',TRUE);
CreateEditText(id,8,'Width Offset',26);
CreateEditText(id,9,'Length Offset',26);

SetFirstLayoutItem(id, 4);
SetFirstGroupItem(id,4,5);
SetRightItem(id,5,6,0,0);

SetBelowItem(id,4,7,0,0);
SetFirstGroupItem(id,7,8);
SetRightItem(id,8,9,0,0);

result := RunLayoutDialog(id,NIL);

END;

RUN(CreateDialog);

I understand how to command vectorscript to draw a rectangle but I am unsure how to connect that command to the dialog box and furthermore I do not know how to make the circles contingent on the overall dimensions of the rectangle.

I am not looking for someone to do my work, I just need assistance on where to look for help. I have read over the Vectorscript reference and done some searches on the function reference but neither explain a great deal to those who are not familiar with coding language.

Any pointers?

Thank you

Link to comment

So I couldn't sleep. Learning challenge accepted!

Seriously though the knowledge base's four examples on this subject are pretty hardcore for beginning! You might find a few bits here on the forum on this stuff but as to the logic I have no idea if it's actually document properly anywhere.

Below is my attempt at your dialog problem. They are a mind bender and I had to refresh my memory with one of my old scripts to see how I'd done it previously.

Sorry it's not annotated better but at least it will give you structure. I've changed most of your fields to Real values as text would just mean an extra conversion step, downside is Static Headers, so you'll noticed the numbering changed in the layout order. I've included a GetEditText field still just so you've got the example for headings and such.

Let me know how you go!

J

PROCEDURE CreateDialog;

VAR

success : BOOLEAN;

id, result : LONGINT;

WidthReal, LengthReal, WidthOffReal, LengthOffReal : REAL;

ExSTR : STRING;

PROCEDURE Dialog_Handler (VAR item :LONGINT; data :LONGINT);

{---------- Values to Vars --------------}

BEGIN

CASE item OF

1:

BEGIN

success := GetEditReal(id,6,3,WidthReal);

success := GetEditReal(id,8,3,LengthReal);

success := GetEditReal(id,11,3,WidthOffReal);

success := GetEditReal(id,13,3,LengthOffReal);

GetItemText(id,15,ExSTR);

END;

END;

END;

{---------- Layout Creation --------------}

BEGIN

id := CreateLayout('Panel',TRUE,'Generate', '');

CreateGroupBox(id,4,'Shell',TRUE);

CreateStaticText(id,5,'Width',28);

CreateEditReal(id,6,3,100,26);

CreateStaticText(id,7,'Length',28);

CreateEditReal(id,8,3,200,26);

CreateGroupBox(id,9,'Armature',TRUE);

CreateStaticText(id,10,'Width Offset',28);

CreateEditReal(id,11,3,25,26);

CreateStaticText(id,12,'Length Offset',28);

CreateEditReal(id,13,3,50,26);

CreateStaticText(id,14,'This is an Example Text Field',40);

CreateEditText(id,15,'An Example Text Field',35);

SetFirstLayoutItem(id, 4);

SetFirstGroupItem(id,4,5);

SetRightItem(id,5,7,0,0);

SetBelowItem(id,5,6,0,0);

SetRightItem(id,6,8,0,0);

SetBelowItem(id,4,9,0,0);

SetFirstGroupItem(id,9,10);

SetRightItem(id,10,12,0,0);

SetBelowItem(id,10,11,0,0);

SetRightItem(id,11,13,0,0);

SetBelowItem(id,9,14,0,0);

SetBelowItem(id,14,15,0,0);

{---------- Run the Layout --------------}

IF VerifyLayout(id) THEN BEGIN

If RunLayoutDialog(id, Dialog_Handler) = 1 THEN BEGIN

{---------- Verify and Make your Rectangles here! --------------}

Message(Concat('WidthReal: ',WidthReal,' Length Real: ',LengthReal,' Width Offset Real: ',WidthOffReal,' Length Offset Real: ',LengthOffReal,' Random Text: ',ExSTR));

End;

End;

END;

RUN(CreateDialog);

Edited by James Russell
Link to comment

Honestly I'd skip the dialog and make it a simple rectangular plug-in instead.

Why ?

- It's regenerative, if you change your mind you can edit it at the fly. Now you need to delete your content and reload the dialog.

- The width / length is handled by the rectangular object, the other data can be parameters editable in the oip

Link to comment
Honestly I'd skip the dialog and make it a simple rectangular plug-in instead.

Why ?

- It's regenerative, if you change your mind you can edit it at the fly. Now you need to delete your content and reload the dialog.

- The width / length is handled by the rectangular object, the other data can be parameters editable in the oip

I did that initially, but I am not sure how I would incorporate the other aspects of the drawing into the OIP. Any information to share on doing this?

Thanks.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...