News:

Please note new Forum URL: forum.designcad.com

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

Drawing true rounded boxes

Started by MarkX, September 27, 2012, 09:31:33 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Lar

#45
Phill,

Edit menu>Selection Edit>Smooth Line By Slope Detection should be what you are looking for. I'm not familiar with it enough to give any pointers. I usually use its twin, Smooth Line By Point Reduction with a 'number of points' value of 5. There is a post somewhere on this forum that explains how to determine the resulting number of points based on this value but I can't explain it.

Lar
ps: if a curve is vector converted it results in more points in tighter curved areas. The point count can then be reduced using smooth by slope detection, if necessary.

prl

Quote from: Dr PR on October 01, 2012, 11:42:27 AM
. . . convert curves into segmented lines with distance between points based upon curvature (few points for straighter sections, many points for sections with great curvature). Sounds like you have a macro to do that. It would be very useful.

Phil, it isn't as fancy as your request.  I never like it when DC creates a million points for curves when combining lines and curves (or circles etc.), so I cobbled this together to limit the number of points.  It's not bullet proof but it does what I need.  Also, I use the first 15 layers in DC as construction layers so in this case I dumped the new segmented line on layer 2.

'program: segit.d3m (segment it)

'  - there is a bug in the query/change dcadalias.d3i approach when reading coordinates if the user
'    uses the origin command during a DC session.  This doesn't happen with the older method of using
'    pointval to read the points.

'general notes:
'  - converts a curved line or circular arc into a segmented line
'  - this version keeps the original curve. The new segmented vector is on layer 2

'DC Segment command behavior notes:
'      curves - the DC segment command converts a curve to a series of straight line vectors that may
'      have more than one two point line per segment. This routine uses only the first and last point of
'      each segment should it consist of more than two points

'      circular arcs - the segment command converts a circular arc to a segmented circular arc.
'      This routine deals with circular arcs by taking the beginning and end points of the arc
'      and uses the points to draw a two point line (a chord).

sys(1116)=0
sys(1)=0
sys(80)=0
start = sys(9)

setpoint "This routine keeps the original curve. Set one point on curve or circular arc to segment", 1

if sys(1)=1 then
  >PointSelect
  {   
    <Type 1
    <UsePresetPoints
  }
else
   END 
endif

if sys(80)=0 then
  Message "Nothing selected. . . routine will END, press any key"
  END
end if

input "Number of segments:", ndiv

sys(36)=2

'copy original curve to clipboard, restore at end.
>SetHandle
{
  <Pointxyz 0, 0, 0
}
>Copy
{
}


>Segment
{
  <segment [ndiv]
  <setpointanddirection 0
  <UsePresetPoints
}
 
gosub FixSegments

>erase
{
}

'restore the copy of the orginal curve or arc
>paste
{
  <type 1
  <pointxyz 0,0,0
}

sys(80)=0
sys(1)=0
sys(36)=0
regen

message "Reminder: Segmented copy is on layer 2, the current layer."

End


'subroutines follow
FixSegments:
sp1 = start

  >line
  {
  <layer 2
  for j = sp1 to sys(9) 
    entity j
   
    epoints = sys(1)
     
    if sys(90) = 1 then 'vector, get first and last points
      pointval ptX1, ptY1, ptZ1, 1
      pointval ptX2, ptY2, ptZ2, epoints
    endif
 
    if sys(90) = 16 then 'circle or circular arc, get second and third points
      pointval ptX1, ptY1, ptZ1, 2
      pointval ptX2, ptY2, ptZ2, 3 
    endif
     
    'now draw two point line
    <pointxyz [ptX1,ptY1,ptZ1]
    <pointxyz [ptX2,ptY2,ptZ2]
   
    getattr j, type
    putattr j, type, 1
  next j
  }

Return


JJG

Quote from: Lar on October 01, 2012, 01:36:44 PM
Phill,

Edit menu>Selection Edit>Smooth Line By Slope Detection should be what you are looking for. I'm not familiar with it enough to give any pointers. I usually use its twin, Smooth Line By Point Reduction with a 'number of points' value of 5. There is a post somewhere on this forum that explains how to determine the resulting number of points based on this value but I can't explain it.

Lar
Yes, same as for me : I use this (Smooth Line By Point Reduction with a 'number of points' value of 5) a lot too.