DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Fill an area with parallel lines

Started by aqua, December 10, 2006, 02:42:13 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aqua

I want to be able to fill an area with parallel lines

Function on menu: Fill an area with parallel lines (set points)
(Also need BasicCAD code to access the above function)

First 2 points will sets row direction
then continue to set points to establish area
Press enter when finished setting points
User input: Enter spacing between lines, say 3
The function fills the area with parallel lines, 3 units apart

Regards FM

DrollTroll

If I recall correctly from your previous discussions, you also want some sort of predictability in the order of those lines, right? Or was that just for processing hatch lines?
25 years with DesignCAD

Rob S

You can do that now by hatching the enclosed area with say ansi 31 hatch pattern.

Adjust hatch scale and angle until the lines are spaced as you want.

A hatch scale of 1 produces for me a spacing of 1.25 units, so that should be easy to do.

Then select the hatch and from the menu "edit, selection edit, convert, explode".
User since forever

aqua

Droll & Rob

Currently to achieve what we want - we use a macro that explodes a line hatch.
It has flaws - the first line is never in the correct position and the each line can be made up of several lines.

i.e the first line should match the first 2 points set, but could be 2 units inwards.
All other lines are then parallel to the location of this first line.
Seed point moving of the hatch may help solve this - but this is more code and doesn't resolve issue 2

Hatch lines may be made up of several lines.
After exploding, we combine all lines of interest but this throws out the order.

I don't think macro code is the answer - and was hoping the feature could be added to the Designcad menu.

And yes, the line order of creation is important, 1 being the line that is the first 2 points set.
All other lines should be numbered as they move away from this first line.
All lines should consist of a single line made up of 2 points

Regards FM

Rob S

With all due respect, I wonder how many users would have need of those exact parameters for a sequence of parallel lines to make it worthwhile to develop the function exactly as you describe.

For now there are SO MANY basic drafting and import/export functions missing or not working as they should which MANY of us need, that this one seems low on the totem pole.

If others would find such a feature useful, please chime in here so it's not one sided!!!

By the way, if you don't have to do this too often, and if the spacing is not too close, you can get the precise results you are asking for with parallel lines and then trim them to the perimeter.
User since forever

aqua

PRL & ROB

In our case, the feature is used to design vineyards and in particular, drip irrigation systems for vineyards.

Myself, and a number of my clients using Designcad are required to do this on a regular basis - so the request is a real and practical one.

I understand that others may not find this useful, however this is the "new feature request" forum.

I have spent a lot of time trying to get the macro code to do this, with a lot of assistance from forum members - but we couldn't quite crack it.

There are suggestions there that might help, i.e offset areas, so we might have to try again.

I have more success in programming using the scalpel (bright ideas -mostly from others) rather than the sledgehammer (hardwork and lots of code) and likewise: I was hoping that the software programmers would find this a simple task.

Regards FM

aqua

Current code to achieve parallel lines



'FTM-2/11/2006

layer(197)=6
sys(3)=197
sys(80)=0

Spacing$ = 0
Input "Enter distance between rows: metres, example 1.52", Spacing$
spacing = spacing$
spacing2 = 0.8 * spacing

Sys(41) = 1
'turn off dialog box
sys(244)=1

setpoint "Set 2 points for direction of rows for new area, then complete hatch area", 2
If Sys(1) < 2 Then

sys(244)=0
sys(41)=0
End
endif

Pointval x1 y1 z1 1
Pointval x2 y2 z2 2
sys(242) = 1
>Line
{
  <LineStyle 0,20.0000,0.0
  <PointXYZ [x1,y1,z1]
  <PointXYZ [x2,y2,z2]
}
>MoveToBack
{
  }
sys(80)=0
Angle1 = 135 + 45 + Angle(x1 - x2, y1 - y2)
>Hatch
{
<PointXYZ [x1,y1,z1]
  <PointXYZ [x2,y2,z2]
  <Scale [spacing2]
  <Angle [angle1]
  <Type 1
  <Name "LINES"
}

>MoveToBack
{
  }

>ZoomWindow
{
  <PointXYZ [x1,y1,z1]
  <PointXYZ [x2,y2,z2]
}

sys(242) = 0

>VectorConvert
{
  }

>ZoomPrevious
{
  }

>Combine
{
  <SelectOnly 0
  }

crckrjck

#7
Not being a macro writer it seems like is should be less complex than you all describe.

In WYSWYG drawing you can draw any closed polyshape, draw a 2 point line at any angle inside or outside the shape, (*2 the length with Info Box [if necessary for extra trim]),  array with set distance X copies [selected when created] (shouldn't we have a perpendicular to a line snap or 'point control'?), then Section Cut by Line 'selection only' keeping inside section only.

Done . . .
:)

Bob P

This may or may not help...

Years ago I wrote a DOS macro to trim a line to a curve, which DC/DOS didn't do natively.  I made it work by converting the curve to a vector curve, trimming the line to the vector conversion, then reverting to the original curve.  The result wasn't exact either.

But what if you didn't revert to the original curve?  You'd still have a good approximation of the curve with a perfect intersection.  The down side is that you'd have many more points (in the "curve") and a larger file size.

crckrjck

If you combine lines and curves into a complex shape, the curves become vectors.

And enabling 'Smart Cutting Line' links touching segments into a single object for this process.

Besides, if you're just laying out a vineyard, aren't you trimming back the rows from the perimeter anyway?
???


aqua

DESIGNCAD 13

PRL, Code written so far

Last time around - this is where we had issues - i.e getting it to draw the parallel lines, in both directions on occassions. Also, then trimming them to suit. We didn't rotate last time - so it may be a bit easier.

Re curves - this should NOT be an issue - it is not proposed that either the internal lines or the boundary are curves - i.e the points set for the boundary will have straight lines joining them - i.e a plane/polygon.

Regards FM



'FTM-11/12/2006
sys(470)=1
el = sys(3)
layer(197)=6
sys(80)=0
Dim X(200)
Dim Y(200)
Dim Z(200)
offset = 50000
Spacing$ = 0
Input "Enter distance between rows: metres, example 1.52", Spacing$
if spacing$ = "" then end
zn = 1
zn = sys(999)
if zn = 1 then end
sys(36)=1
spacing = spacing$
if spacing = 0 then end
sys(36)=0
spacing2 = 0.8 * spacing
Blockcount = 1
Sys(41) = 13
'turn off dialog box
sys(244)=1
sys(1)=0
setpoint "Set 2 points for direction of rows for new area, then complete hatch area", 200
If Sys(1) < 3 Then
Sys(41)=0
Sys(244)=0
sys(3)=el
End
endif

Sys(36) = 1
npts = sys(1)
For i = 1 to npts
   Pointval x(i) y(i) z(i) i
next i

sys(3)=197

'Select object when created
sys(242)=1
>plane
{
for i = 1 to npts
<pointxyz [x(i)+offset, y(i), 0]
next i
}
sys(242)=0

For i = 1 to 2
   Pointval x(i) y(i) z(i) i
next i

Firstx = x(1)+offset
Firsty = y(1)
Secondx = x(2)+offset
Secondy = y(2)

'
Angle1 = Angle(Secondx - Firstx, Secondy - Firsty)
>Rotate
{

  <Angle [0-Angle1]
}


'6.  Programmatically fill in the parallel lines covering the shape.
'Because you rotated the shape to the x axis, all the lines are simply horizontal lines.
'Query the bounding box of the shape to define the maximum length of the horizontal lines needed.

'Min & max - x & y of selected polygon/plane

minxsel = sys(196)
minysel = sys(197)
maxxsel = sys(198)
maxysel = sys(199)


'Obtain x & y values of selected object
x1 =
y1 =
x2 =
y2 =
x3 =
y3 =


'Need to determine if points set in clockwise or anti-clockwise direction or both
'Issue - some shapes will require lines to be added in both above and below
'If y3 > y1 then add lines above
'if y3 < y1 then add lines below
'if ?????? then add lines above and below

'Select object when created
sys(242) = 1

Ydistance = maxysel - minysel
ydistance2 = 0
Repeat:
>Line
{
  <LineStyle 0,20.0000,0.0
  <PointXYZ [minxsel,y1,0]
  <PointXYZ [maxxsel,y1,0]
}
'Identify x & y of last line set
>Parallelbydistance
{
  <PointXYZ [,  ?  ,0]
  <Distance [spacing2]
}

ydistance2 = ydistance2 + spacing2
If ydistance2 < ydistance - spacing2 then goto repeat


>MoveToBack
{
  }

'7.  Use section trim, keep inside to trim all the lines to the boundary shape.



'8.  Select the trimmed lines and rotate them back to the original angle.

>Rotate
{

  <Angle [Angle1]
}

'9.  Select the lines again and translate them back to the original position.

>Move
{
}

sys(80)=0



aqua

#11
PRL

I get an error at the ThroughHandle 1 part

Note: I am using Designcad 13

On my code - getting the required angle was easy - getting it to add lines in the required direction was going to be the challenge.

Also re the attached drawing. If the area bends back on itself, it doesn't draw the lines correctly - i.e fills the area outside of the shape. We had this same issue when attempting to write the original code.

Regards FM




...........
>rotate
{
  <angle [rot]
  <ThroughHandle 1
}

aqua

PRL

When I ran a similar test (but not exact - I deleted the original drawing), it got the lines correct - so now I'm not sure if I somehow set the points wrong.

I will try and add some of my code into yours, example, we use a plane rubber band and the first 2 points set for direction do not need to be set again, i.e the first 2 points represent the direction but also are part of the area.

V13 is reliable - except for the occasional freeze up of outside controlling programs when Designcad gets instructions whilst it is still completing a task.

V14 & V15 had a number of issues - as did the early V16.
There has also been no developers kit after 13 - and we rely heavily on an outside program to work with Designcad.

V17.1 Toolbars are still an issue.

To date, all the new versions after V13 have not offered anything extra that we could utilise.

With DrollTroll back - the developers kit might finally be released. So an upgrade is on the cards for next year. Maybe 17.2 will be perfect!

Thanks for all your help on this one.

Regards FM

dmeek

Quote from: prl on December 12, 2006, 02:29:41 PM
Frank, I'm glad if it helps you.  Hate to have it go to waste. 
This is a good example for anyone learning to use BasicCAD.
Probably a good addition to "User Contributions", and the "Sample Macros" in the DesignCAD Installation.

support

Also if you do not need actual vector lines there is a hatch pattern ANSI31 that can be used in any of the hatch commands to fill an area with parallel lines. You can adjust the angle of the lines using the hatch angle and can also adjust the space between the lines some what by changing the scale.