Jump to content
Sign in to follow this  
neeboy

no offset in Vectorscript??

Recommended Posts

PLEASE do not NOT tell me I can't use the offset command in Vectorscript...if it's not there, I wil be appalled! Has anyone seen it?

Share this post


Link to post

Hi, AFAIK there's no offset function in VS.

Which object(s) do you want to offset?

Are these always the same objects?

Say you have rectangles or ovals it's

easy, but with polygons or polylines...

Share this post


Link to post

On VectorWorks 10 you have

FUNCTION ??OffsetPoly

( ? hPoly :HANDLE;

? ? dist :REAL

) :HANDLE ;

Description: Creates a new polyline or polygon from the referenced poly using the specified offset value.

[uPDATE: Now I know this function is NOT similar to the Offset Tool]

[ 10-10-2003, 07:40 AM: Message edited by: Alexandre B A Villares ]

Share this post


Link to post
Guest

I've used this offset polytool. It only allows offset by point mode. It is very frustrating!!!! I had to design my own offset tool which was pretty tricky and time consuming.

Good Luck.

Share this post


Link to post

quote:

Originally posted by dfortin:

I've used this offset polytool. It only allows offset by point mode. It is very frustrating!!!! I had to design my own offset tool which was pretty tricky and time consuming.


Hi Dfortin,

What do you mean by 'point mode' ?

Isn't the function dist . mode based?

Would you be willing to sell your code ?

(I have many VW9.5 clients and some of my new tools might need the VS10 offsetpoly call).

PS: I wish the VW offset tool would produce a polyline...

Share this post


Link to post
Guest

Basically OffsetPoly offsets polygons from their original location to a user defined distance in the X direction.

This is not what were looking for we need a true offset tool.

PS. Alexander I would like to sell you my code. The only problem is that I think that I would be fired for it.

Share this post


Link to post

quote:

Originally posted by dfortin:

PS. Alexander I would like to sell you my code. The only problem is that I think that I would be fired for it.

Ops! I apologise for even asking then.

Share this post


Link to post

Yes I have used this in a script .What a misnomer it should be called X axis duplicate function .I hope they really do provide a real offset function soon . I thought this was the whole idea of scripts to do what You can manually into a scripted form . Come on NNA crank it up a bit .

Share this post


Link to post

Never realized the offset was missing, but I never found the Trim and Extend functions, and at the end develop my own Trim procedure.

Offset a poly (plygon and polyline) on a vs work relatively well with a bit of trigo on the vertex:

Say a (x,y) vertex, a,b the angles from/to the two adjacent vertex and ofs my offset value the simplify formula looks close to:

Xnew:=x+( ofs*(Cos (a)+Cos (-b)) );

Ynew:=y+( ofs*(Sin (a)+Sin (-b)) );

The open ends need a modif but the general idea is the same.

The angles need a good control: they can change the side for the offset, and should be in radiants for the trigo funtions.

I use a similar formula (but on 3D) to work on nurbs, but the first study was done on polys.

Share this post


Link to post
Guest

This is a good starting point for an offset tool and was a first idea that I had as well. The problem with this aproach is that each line of the newly offset polygon will not be parallel with it's original counterpart.

ie. If you draw a polygon with many obtuse and acute angles and use the graphical offset tool to offset the poly one inch, you will see that each vertex is not always exactly one inch from the original. If you move them to one inch it distorts the shape of the new polygon.

The path you need to go down is to copy the polygon, convert it to lines, figure out the angle of each line, use the cosine and sine rules to figure out where to move the center of that line, then move all the lines to there location, and finally join them all together. The tricky part is knowing what is the inside of the polygon and what is the outside. The offset tool that I have developed is for polygons only because I have no way of determining what side of the poly line to offset to.

Good luck!

Share this post


Link to post

I think this is the point of it all .I have spent a number of hours working this problem to .It would save much if this was a workable function or at least an accessible DomenutextByName.

Its not helping all of us scratching around doing our own thing with code no-one really wants to share .

Share this post


Link to post

Sorry, I can not give the full develop formula.

But, here goes one of the first offset procedures I did when I start to torture nurbs.

He only work with 3 vertex (2 sides) polygons and polylines: up to you to clean up my mess and work with arrays to increase the n? of vertex.

He will fist ask you to click on the poly to offset, then on the side you want the offset and finally the value.

AlexandreBA Villares... where is the check?

code:

Procedure Offset;

VAR

x,y,x1,y1,x2,y2,xs,ys,a,b,c,e,off: REAL;

d,t: INTEGER;

h,h1,h2,h3: HANDLE;

o,u: BOOLEAN;

p1,p2,p3,p4:POINT;

BEGIN;

GetPt(x,y);

h:=PickObject(x,y);

t:=GetType(h);

Message (t);

GetPolylineVertex(h,1,x,y,d,a);

GetPolylineVertex(h,2,x1,y1,d,a);

GetPolylineVertex(h,3,x2,y2,d,a);

GetPtL(x,y,xs,ys);

MoveTo(x,y);

LineTo(x1,y1);

h1:=LNewObj;

a:=HAngle(h1);

MoveTo(x1,y1);

LineTo(x2,y2);

h2:=LNewObj;

b:=HAngle(h2);

MoveTo(x,y);

LineTo(xs,ys);

h:=LNewObj;

c:=HAngle(h);

e:=90;

IF c<a Then e:=-90;

DelObject(h1);

DelObject(h2);

DelObject(h);

off:=RealDialog('OffsetValue','0');

p1.x:=x+( off* Cos(Deg2Rad(a+e)) );

p1.y:=y+( off* Sin(Deg2Rad(a+e)) );

p2.x:=x1+( off* Cos(Deg2Rad(a+e)) );

p2.y:=y1+( off* Sin(Deg2Rad(a+e)) );

p3.x:=x1+( off* Cos(Deg2Rad(b+e)) );

p3.y:=y1+( off* Sin(Deg2Rad(b+e)) );

p4.x:=x2+( off* Cos(Deg2Rad(b+e)) );

p4.y:=y2+( off* Sin(Deg2Rad(b+e)) );

LineLineIntersection(p1,p2,p3,p4,o,u,p2);

IF t=5 Then Smooth(0);

IF t=21 Then Smooth(1);

BeginPoly;

AddPoint(p1.x,p1.y);

AddPoint(p2.x,p2.y);

AddPoint(p4.x,p4.y);

EndPoly;

END;

Run (Offset);
[/code]

Share this post


Link to post

Cheers Kiwi thats a shunt in the right direction.

Are you watching our All Blacks this weekend.

Brendan

Share this post


Link to post

Here my own Poly Offset studies, it works on n-sided closed polygons and I think it solves the inside/outside problem (this code draws some offset locus on the outside of the selected polygon):

code:

 Procedure PolyOff;

VAR

pHd : HANDLE;

i, n, Vtype : INTEGER;

D, A, Vradius : REAL;

M :VECTOR;

C, V0,V1, V1A, V1B, V2, VF :POINT;

B1, B2 : BOOLEAN;

BEGIN

{*} pHd:=LSActLayer;

{*} IF pHd <>NIL THEN BEGIN

D:=RealDialog('Offset Dist.','1');

n := getVertNum(pHd);

FOR i:=1 to n do BEGIN

IF i=1 THEN BEGIN

GetPolylineVertex(pHd, n, V0.x, V0.y, Vtype,Vradius);

GetPolylineVertex(pHd, i, V1.x, V1.y, Vtype,Vradius);

GetPolylineVertex(pHd, i+1, V2.x, V2.y, Vtype,Vradius);

END ELSE IF i<n THEN BEGIN

GetPolylineVertex(pHd, i-1, V0.x, V0.y, Vtype,Vradius);

GetPolylineVertex(pHd, i, V1.x, V1.y, Vtype,Vradius);

GetPolylineVertex(pHd, i+1, V2.x, V2.y, Vtype,Vradius);

END ELSE BEGIN

GetPolylineVertex(pHd, i-1, V0.x, V0.y, Vtype,Vradius);

GetPolylineVertex(pHd, i, V1.x, V1.y, Vtype,Vradius);

GetPolylineVertex(pHd, 1, V2.x, V2.y, Vtype,Vradius);

END;

MoveTo (V0.x, V0.y);

LineTo (V1.x, V1.y);

HCenter(LNewObj,C.x,C.y);

A:=HAngle(LNewObj);

DelObject(LNewObj);

M:=Ang2Vec(A+90,0.001);

IF PtInPoly(C.x+M.x,C.y+M.y,pHd)

THEN M:=Ang2Vec(A-90,D)

ELSE M:=Ang2Vec(A+90,D);

V0.x:=V0.x+M.x; V0.y:=V0.y+M.y;

V1A.x:=V1.x+M.x; V1A.y:=V1.y+M.y;

LineTo (V2.x, V2.y);

HCenter(LNewObj,C.x,C.y);

A:=HAngle(LNewObj);

DelObject(LNewObj);

M:=Ang2Vec(A+90,0.001);

IF PtInPoly(C.x+M.x,C.y+M.y,pHd)

THEN M:=Ang2Vec(A-90,D)

ELSE M:=Ang2Vec(A+90,D);

V1B.x:=V1.x+M.x; V1B.y:=V1.y+M.y;

V2.x:=V2.x+M.x; V2.y:=V2.y+M.y;

LineLineIntersection(V0,V1A,V1B,V2, B1,B2, VF);

Locus(VF.x,VF.y);

END; {of FOR}

{*} END;

END; run(PolyOff);
[/code]

PS: Kiwi, I've sent you a private msg! [Wink]

[ 10-09-2003, 09:52 PM: Message edited by: Alexandre B A Villares ]

Share this post


Link to post
Guest

We are aware of the problems with the OffsetPoly function. It is on our wishlist, and we are working on it.

Jeff

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...