Jump to content
Developer Wiki and Function Reference Links ×

Custom PIO: need help creating small symbol, please


Recommended Posts

Trying to wrap my head around Vectorscripting. I'm not a coder from scratch but am decent at looking a preexisting code, figuring out sections, and tweaking it.

I currently have a symbol created of the attached screenshot. I attached a record and adjust the Letter Label (top) and the Length Label (bottom) in the Object Info under the data tab.

I'd rather have this as a Plug in Object so that I can quickly select and adjust multiples quickly. Using examples I've found online, I've been able to piece code together and create a simple box with two text fields. These are the things I want it to do and am stuck.

1. Hexagon shape with a bold line dividing top and bottom half. Center is the 0,0 insertion point.

2. Color fill with 60% transparency. Ability to change colors in the Object Info 'Shape' tab. (Pink, Cyan, Yellow, Green, Orange)

3. Top field for text. Editable in OI.

4. Lower field for text. with the ' suffix (for feet). But not a 'number' field.

Thanks in advance for any help/guidance

Scott

Link to comment
  • 3 weeks later...

Know that 0,0 the origin of a PIO is the same concept as a symbol. Where you click the mouse during placement is 0,0 inside the PIO environment for a Point type PIO.

I you are new to programming code/languages and don't think you can juggle all the process in your head write it on paper.

Take a shell script as your starting point, no code between the first Begin statement final End statement. Determine you input parameters. Know that when retrieving their values in your code you place a 'p' in front of the name you gave them.

You need three for this project; two text types and one drop down list. The latter for the colours.

Know that a Handle variable is like a leash to your dog. So immediately after creating an object like your Hexagon or text field you will want to capture and store in a variable its handle. This is primarily true if you set all the object's characteristics after its creation instead of before or during creation. I find it easier to search for and understand the commands I need by having the language guide open on a second screen in my web browser.

Try using BeginPoly; AddPoint(x,y);...EndPoly; for your hexagon. You can capture the 6 vertices of the hexagon in your symbol and use them if the hex is centred on 0,0. Getting your text placement to your liking is similar but may be a little harder the first time around.

Link to comment

Scott -

While not in a PIO shell, here is some quick code that will create a red hexagon with partial opacity and add a middle line. I hope this helps in your endeavor...

PROCEDURE HexBox;

CONST

HexShortRad = 8";

OriginX = 0;

OriginY = 0;

VAR

LongRad,HalfFace : REAL;

HexHandle,LineHandle : HANDLE;

BEGIN

LongRad := HexShortRad/(Cos(Deg2Rad(30)));

HalfFace := HexShortRad*(Tan(Deg2Rad(30)));

BeginPoly;

AddPoint(OriginX+HalfFace,OriginY+HexShortRad);

AddPoint(OriginX+LongRad,OriginY);

AddPoint(OriginX+HalfFace,OriginY-HexShortRad);

AddPoint(OriginX-HalfFace,OriginY-HexShortRad);

AddPoint(OriginX-LongRad,OriginY);

AddPoint(OriginX-HalfFace,OriginY+HexShortRad);

AddPoint(OriginX+HalfFace,OriginY+HexShortRad);

EndPoly;

HexHandle := LNewObj;

SetLSN(HexHandle,1);

SetPenFore (HexHandle,0,0,0);

SetPenBack (HexHandle,0,0,0);

SetLW(HexHandle,40);

SetFPat (HexHandle,2);

SetFillFore (HexHandle,65535,0,0);

SetFillBack (HexHandle,65535,0,0);

SetOpacity(HexHandle,60);

MoveTo(OriginX-LongRad+1",0);

LineTo(OriginX+LongRad-1",0);

LineHandle := LNewObj;

SetLSN(LineHandle,1);

SetPenFore (LineHandle,0,0,0);

SetPenBack (LineHandle,0,0,0);

SetLW(LineHandle,16);

END;

RUN(HexBox);

Link to comment
  • 1 month later...

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...