Jump to content
Developer Wiki and Function Reference Links Read more... ×
Sign in to follow this  

Drawing hatch pattern type lines on polygon

Recommended Posts

I'm trying to draw hatch pattern type lines on polygon instead of using hatch itself. It's for use in path PIO. The given data would be:

1. poly handle

2. rotation

3. spacing

4. offset distance from 0

The attached pic represents what I want. It's achieved with hatch. I want to make it with lines. The main confusion is about how to determine where the line should start, where end and what to do in case on same line there are 2 or more lines (other words - the line is interrupted by shape of poly). I've just started working on this and haven't developed any solutions yet. The solution isn't obvious this case, so I'm hoping somebody else might have vision or solution for this.

Share this post

Link to post

The direction I'm thinking about is GetBBox and LineLineIntersection usage widley.

Share this post

Link to post

Hi Yancka,

You may want to use CreateStaticHatchFromObject:

FUNCTION CreateStaticHatchFromObject(inObj :HANDLE; inHatchName :STRING; pX, pY :REAL; rotationAngle :REAL) :HANDLE;

This places a static hatch (inHatchName) within the polygon (inObj) at point (Px, Py) with an angle (rotationAngle). You would still need to have a hatch in the document to use but it'd probably be much faster (and easier) than trying to slice and dice a bunch of lines. If the needed hatch resource is not already in the document, you could create it before inserting it. Then, if desired, the PIO could delete it so the user doesn't see it in the RB).

Long long ago I developed a similar approach to what you're proposing (before the CreateStaticHatchFromObject call existed). It would create the array of lines over the polygon (making sure to cover it's BBox), bring the polygon to the front, then Intersect Surface (I think). Not nearly as elegant...


Share this post

Link to post

Hi Matt,

CreateStaticHatchFromObject really does the trick but it requires to mess with hatches in drawing. So I decided not to go with hatches but do a bit more hairy way of combining GetBBox, AddHole and ClipSurface. The result is as desired - 1 contour poly and a bunch of lines. Just I don't yet get how to make out of it what I'm intending (I thought this would be easy from this stage but it isn't).

I want to get start point and end point information of each line, delete the line and place linear PIO instead (just 1 level PIO nesting at this point). I don't find a way to get handles of line segments after applying ClipSurface and somehow I'm not succeeding with ForEachObject within my path PIO. But I have all lines selected within my PIO (I can delete them with DeleteObjs call). Any hints on way of cycling through this bunch of lines and converting then into linear PIOs?

Share this post

Link to post

Hi Yancka,

Have you tried creating the lines in a group and giving the group a handle? something like this:


{create all the lines for cutting}


GroupHand := LNewObj;

{ now create a copy of the PIO's path poly and send it into the group }

CuttingPolyHand := CreateDuplicateObject( pioPathPolyHand, GroupHand );

{ do all your clipping and delete the clipping objects }

ForEachObjectInList( Convert2PIOProc, 0, 1, FInGroup( GroupHand ) );



Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
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.