Jump to content
Developer Wiki and Function Reference Links ×

Plug in scripting question


Recommended Posts

I'm new to vectorscript and trying to make a set of plug-ins for the UK beam library. There are metric and imperial North American beams included with VW12 but not for the UK sizes. I've started with the following script:

BEGIN

result:= GetCustomObjectInfo(objname, oh,rh,wh);
IF result THEN BEGIN

Otype := PTYPE;

IF Otype = '100 X 50' THEN PFCtype := 1
ELSE PFCtype := 2;

CASE PFCtype OF
	1: BEGIN
	H := 100;
	W := 50;
	Tf :=7;
	Tw := 5;
	END;

	2: BEGIN
	H := 180;
	W := 75;
	Tf :=10;
	Tw := 5;
	END;
END;

PushAttrs;
FillPat(2);
Poly(0,0, 
	W,0, 
	W,Tf, 
	Tw,Tf, 
	Tw, H-Tf, 
	W,H-Tf, 
	W,H, 
	0,H, 
	0,0);
PopAttrs;

END;

END;

Run(Box1);  

But I have a few questions.

1. How do I introduce a fillet to the channel. I couldn't find a function for Fillet in vectorscript and also wouldn't know how to reference the appropriate corners that are to be filleted.

2. Can I set up an array of values for the different channel sizes. ie:

100x50: 100 150 7 5

180x75: 180 75 10 5

etc. so that I could set up my 'CASE' portion of the code to just search the array of values.

Thanks for any help. Also are there any sites with examples of various scripts that I can go to?

Andreas

Link to comment

Your Polygon can also be written as:

	ClosePoly;		{ if you want it closed, recommded }
BeginPoly;
	MoveTo(0, 0);
	LineTo(W, 0);
	LineTo(W, Tf);
	LineTo(Tw, Tf);
	LineTo(Tw, H-Tf);
	LineTo(W, H-Tf);
	LineTo(W, H);
	LineTo(0, H);
	LineTo(0, 0);		{ optional }
EndPoly;

If you want to fillet the two inside corners:

	ClosePoly;
BeginPoly;
	MoveTo(0, 0);
	LineTo(W, 0);
	LineTo(W, Tf);
	ArcTo(Tw, Tf, 5);
	ArcTo(Tw, H-Tf, 5);
	LineTo(W, H-Tf);
	LineTo(W, H);
	LineTo(0, H);
	LineTo(0, 0);		{ optional }
EndPoly;

For examples in coding, goto VectorDepot (www.VectorDepot.com)

HTH,

Raymond

Link to comment

Raymond,

thank you so much. That is a much nicer way of doing a polyline! Does the ArcTo(x,y,r) fill in the straight line between the two corners? It makes an arc that ends at (x,y) and then a straight line from the tangent to the previous point. I didn't get that at all from the help file!

Thanks again,

Andreas

Link to comment

Hi Andreas,

Always happy to help. Yes, ArcTo does continue the straight line segment from the last point.

One thing to note, ClosePoly and its converse OpenPoly stay in effect until changed, so you don't need one for each BeginPoly. Also, it is a good practice for most Polylines to start and end with Corner Points - MoveTo and LineTo. For Open Polylines, it's always necessary.

Raymond

Edited by MullinRJ
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...