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.

Bearing Command

Started by G-Bob, May 16, 2012, 04:59:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

G-Bob

I have reworked the geo macro to suit how I have laid down the bearings in a file
It works fine
Years ago I had the same before I had machine failure, and I was able to automatically label the bearings on the drawing when all boundaries were drawn
I have since tried many ways but I cant get it to work

>SetStartPoint
   {
      }
   
    >Line
      {
      <Pointxyz 0, 0, 0
      do while not eof(1)
      input #1, dist$,ang$
                     
      dist=val(dist$)
       ang = val(ang$)
      
        if sys(23) = 0 then ang = 90 - ang
         <PointPolar [dist],[ang],0
            
      Loop
   
      }
        close #1

Can anyone show me how to follow from here with the bearings command to automatically label the drawing
I have used sys(800) to watch the output
I can't seem to pick up the points as it goes around the block

Thanks in advance

prl

Hi Bob,

Next step is to read the last entity drawn, in this case the line, read the points via pointval, store them in a dimension array,  and then do the >ID_BEARING loop. Here is some code snippet to store the points:


' Get the points for the line just drawn
Entity sys(9)

tpoints = sys(1)
for j = 1 to tpoints
  Pointval jx(j), jy(j), jz(j), j
next j


prl

#2
Bob, here is a working version that reads data from a file, draws the line and then reads the line data to add the bearing labels.  Feel free to pull it into your programming scheme as needed.  If you do something really fancy and you care to share, post it in the basiccad section.

I've attached the sample data file and a screen capture of the final result.  Ensure you double check everything.  At one time the point polar parameter would not honor geographical angles even if you told it so in the sys(23).  Make sure the boundary is turning the way you expect and the labels are oriented to your standards.  I just picked something.  See the getangle subroutine.  

'Program: geoplot.d3m (uses file to read survey data)

'sample input file format - distance then angle in degrees
'48.25        93.775
'18.38        177.675
'50.20        273.775
'18.28        3.775

'Notes -
'  geographical angles use Y axis as zero and turn clockwise

dim jx(100), jy(100), jz(100)

sys(23) = 0 ' Mathematical or geographical angles [1 = Mathematical, 0 = Geographical]
sys(36)=1 'silent mode

gosub 2d_draftmode 'switch to 2d mode if needed

infile$="V:\Combined Data4"
fmt$ = "%s        %s"
Precision 15
open "i", 1, infile$


>line 'used arrow to trace which way survey is turned
{
 <Type 1
 <Pointxyz [0, 0, 0] 'all start at origin
 do while not eof(1)
   input #1, a$
   Parse a$,fmt$, dist$, ang$
  'message dist$, ang$
   ang = val(ang$)
   if sys(23) = 0 then ang = 90 - ang
   dist = val(dist$)
   <PointPolar [dist], [ang], 0
 loop
}
close #1

gosub AddLabel
sys(1)=0
sys(80)=0
>fittowindow
{
}
regen
End




'subroutines follow
'Get the points for the line just drawn
2d_draftmode:
 if Sys(344) = 0 then 'in 3d mode, switch to 2d
  >2DMode
  {
  }
 end if
Return


AddLabel:
Entity sys(9)
tpoints = sys(1)

'message tpoints

for j = 1 to tpoints
  Pointval jx(j), jy(j), jz(j), j
next j

segments = tpoints - 1

for j = 1 to segments
   x1 = jx(j)
   y1 = jy(j)
   
   z = 0
   
   x2 = jx(j+1)
   y2 = jy(j+1)
   
   xt=(x2-x1)/2.0+x1
     yt=(y2-y1)/2.0+y1
     z3=(z2-z1)/2.0+z1
     
     gosub getangle
 
  >ID_BEARING
      {
       <Color 255,255,255
       <Layer 1
       <PointXYZ [x1,y1, z]
       <PointXYZ [x2,y2, z]
       <PointXYZ [xt,yt, z]
       <VectorFont "simplex2w"
       <FontType 1
       <Style 0
       <Justification 1
       <Size 8.000000000000000e-001
       <Type 0
       <DistanceFormat 0
       <AngleFormat 4
       <AnglePrecision 0
       <DistancePrecision 0
       <Reverse [orienttext]
       }
next j
Return

getangle:
 xd = (x2-x1)
 yd = (y2-y1)
 
 if abs(xd) < 0.000001 then xd = 0 'declare as zero
 if abs(yd) < 0.000001 then yd = 0 'declare as zero
 
 'first quadrant
 if xd > 0 and yd >= 0 then orienttext = 0
 
 'second quadrant
 if xd < 0 and yd >=0 then orienttext = 1

 'third quadrant
 if xd < 0 and yd <0 then orienttext = 1

 'fourth quadrant
 if xd > 0 and yd < 0 then orienttext = 0
 
 'special orthogonal cases
 if xd = 0 and yd > 0 then orienttext = 1
 if xd = 0 and yd < 0 then orienttext = 0
 
 if xd = 0 and yd = 0 then end
Return


G-Bob

Thanks prl

I have integrated your code and it is working with my files okay
I am adjusting the offset with the label (not to have it sit on the line) ... having partial success (but I will get it  :)

I admire the direction logic for the labels

Thanks again
G-Bob

when I am 110% I will post on forum

prl

Bob,  

I guess I need to be more careful.  The code I posted runs in version 15.3.  The Parse statement works differently in 16 to 21.  Here is a fix.  I'm assuming you already did this but in case someone else needs this.

.
.
.
gosub 2d_draftmode 'switch to 2d mode if needed

infile$="V:\Combined Data4"

Precision 15
open "i", 1, infile$

>line
{
 <Pointxyz [0, 0, 0] 'all start at origin
 do while not eof(1)
   input #1, dist, ang
   if sys(23) = 0 then ang = 90 - ang
   <PointPolar [dist], [ang], 0
 loop
}
close #1

.
.
.