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.

Uniform segmented arcs

Started by Dr PR, April 06, 2011, 10:44:32 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Dr PR

V20.1

There is an annoying characteristic of the "Draw/Arcs/Arc(center, begin, end)" and "Draw/Arcs/Arc(3 point)" functions that should be fixed.

If you draw an arc, select "Draw as a line" and give an even number of points, an many (most, all?) cases the line segments will not all be the same length. This makes segmented arcs useless for a quick way to divide an angle into any number of angles.

It would be nice if all segments of these arc/lines were of equal length.

As it is, you must draw an arc without "Draw as a line" selected, then use the "Ticmarks" function to subdivide the arc into segments and then draw the segmented arc with the Line (V) command. That is a lot of unnecessary work.

DesignCAD user since 1987

Lar

This has always been the case in and I would also like to see it fixed. My main problem with it is that it never finds the center of the arc (with an even number of segments).

This is why in the other post about extruding along a curve I said I always use vectors. If I extruding along an arc or even using one to turn into a plane I always create half the arc then mirror and combine it so I have the center. If I need equal segments or a precise angle I would use circular array to spin a radius-line then draw the vector-arc.

Lar

paulerens

'Hi guys,
'This macro makes from a arc3, a vectorized arc with exact segments.
'=================================================
>Arc3
{
<Type 0
}
Sys(36)=2
Input"How many segments?",S
GetSelect 1,j
Entity j
Last= Sys(1)-1
PointVal x20 ,y20 ,z20 ,Last
>Segment
{
<LineSnap [ x20 ,y20 ,z20 ,Last]
<Segment
}
Sys(80)=0
>SelectPrevious
{
}
a = Sys(80)
Punten = Sys(80)*3
Dim x(Punten)
Dim Y(Punten)
Dim z(Punten)
For i = 1 To Sys(80)
getselect i,j
Entity j
L = 2
last = Sys(1)
Pointval x(i),y(i),z(i),L
Sys(81)=1
pu = pu + 1
Next i
>Erase
{
}
>Line
{
For i = 1 to a
<Pointxyz [x(i),y(i),z(i),L]
Next i
<Pointxyz [x20 ,y20 ,z20 ,Last]
}
>Deselect
{
}
Sys(36)=0
Regen

paulerens

I do not know where the lines come from
If you copy and past, they go away.

Lar

Paul, before pasting in the code click the code button (the # above), then paste the code in between the sets of square brackets. This will put the code in its own box so the basiccad statements don't generate smilies and other stuff when the message is posted.

Lar


Lar

Paul, the macro didn't work at first because it didn't select the arc. I inserted the necessary code and it worked beautifully except that it always produced 10 segments (which, I learned, is the default for the segment command, in my system, anyway). It seems the 's' in Input"How many segments?",S wasn't used again in the macro. I then added s  in square brackets (***this is what produced the strikethroughs in the rest of your macro*****) to <Segment and it worked beautifully. But, I realized that during the testing if anything was selected before the macro was called up they would get deleted, and if more than one entity was selected the macro would produce a straight line somehow, so I added code at the start to deselect everything.

The full code is below. I highlighted my stuff with asterisks. Y'all folks can delete them.

Lar



'forum contribution by 'paulerens', 17April11
'This macro makes from a arc3, a vectorized arc with exact segments.
'=================================================

'*******added by Lar:
'deselect everything, or selected stuff will get deleted by this macro...
sys(80)=0
'*******

>Arc3
{
<Type 0
}

Sys(36)=2

Input"How many segments?",S

'**********
'select last entity
GetAttr sys(9), type, select
select=1
PutAttr sys(9), type, select
'**********

GetSelect 1,j

Entity j

Last= Sys(1)-1

PointVal x20 ,y20 ,z20 ,Last

>Segment
{
<LineSnap [ x20 ,y20 ,z20 ,Last]
<Segment [s]
}

Sys(80)=0

>SelectPrevious
{
}

a = Sys(80)
Punten = Sys(80)*3
Dim x(Punten)
Dim Y(Punten)
Dim z(Punten)

For i = 1 To Sys(80)
getselect i,j
Entity j
L = 2
last = Sys(1)
Pointval x(i),y(i),z(i),L
Sys(81)=1
pu = pu + 1
Next i

>Erase
{
}

>Line
{
For i = 1 to a
<Pointxyz [x(i),y(i),z(i),L]
Next i
<Pointxyz [x20 ,y20 ,z20 ,Last]
}

>Deselect
{
}

Sys(36)=0
Regen

paulerens

Lar,
Normally, I work with  Select Object When Created on
With Sys (242) = 1 in the code, it also works well. The arc remains selected.
Thank You for the justified comments.
Paul.

Lar

Select Object When Created being on certainly simplifies the code writing. But for those of us who don't normally have it on the code should probably say: at the beginning 'if sys(242) is off then turn it on' then at the end 'if it was off at the beginning then turn it back off'.

There is also something else happening which I noticed last night but did not understand why, but now I partly do: let's say you snap to existing lines to set the points of the the arc3. Then the existing line at point-1 gets segmented - since dcad chooses it with the <linesnap in the >Segment command -  and the arc (the one created in the macro) becomes a straight line (this is the part I don't understand yet). If the entity at point-1 is an arc then it gets segmented but each segment is an individual arc entity.

This method dcad has of clicking on entities to select them for command operations (especially solid operations) has caused me many a headache during macro writing. I am normally forced to move the entities to be operated on to empty layers and turn all the other layers off, then return everything to its former state afterward.

Lar

paulerens

#8
Lar,
Here is a new version of the macro.
MoveToBack making from the entity the lowest number and  the entity will be selected first
'*******added by Lar:
'deselect everything, or selected stuff will get deleted by this macro...
sys(80)=0
'*******
Sys(1150)=1                   'Command bar OFF
Sys(130)=1
Sys(131)=50
If not Sys((242)) Then         'If Select object when created =OFF
Sys(242)=1                     'Select object when created =ON                  
sel = 1
End If
>Arc3
{
<Type 0
}
>MoveToBack
{
}
Sys(36)=2
Input"How many segments?",S
GetSelect 1,j
Entity j
Last= Sys(1)-1
PointVal x20 ,y20 ,z20 ,Last
>Segment
{
<LineSnap [ x20 ,y20 ,z20 ,Last]
<Segment [s]
}
Sys(80)=0
>SelectPrevious
{
}
a = Sys(80)
Points = Sys(80)*3
Dim x(Points)
Dim Y(Points)
Dim z(Points)
For i = 1 To Sys(80)
getselect i,j
Entity j
L = 2
Pointval x(i),y(i),z(i),L
Next i
>Erase
{
}
>Line
{
For i = 1 to a
<Pointxyz [x(i),y(i),z(i),L]
Next i
<Pointxyz [x20 ,y20 ,z20 ,Last]
}
>Deselect
{
}
Sys(1150)=0
If sel > 0 Then
Sys(242)=0
End If
Sys(36)=0
Regen

Lar

Thanks Paul. Works perfectly.

Lar

DrollTroll

Not to invalidate paul's hard work, but I think we may have a fix for this soon :D
25 years with DesignCAD

paulerens


Dr PR

DT,

We will scatter rose petals at your feet ...
DesignCAD user since 1987

DrollTroll

Start stealing roses from that little old lady next door then :D
25 years with DesignCAD