AutoCAD Land Desktop (Read Only)
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Convert Radians to Bearing?

13 REPLIES 13
Reply
Message 1 of 14
Anonymous
3217 Views, 13 Replies

Convert Radians to Bearing?

Using VBA in LDT3, what is the best way to convert the angle of a line from
Radians to either an Azimuth or Bearing?

TIA, Gene
13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: Anonymous

Off the top of my head you multiply by 180/pi to get the azimuth from
radians.

Depending on what format you want the output to be in you may need to use:

angletoreal and angletostring for conversion.

If you let me know the desired output I'll send you better instructions.

Bud Miller
www.BudCAD.com
Legal Descriptions. Parcel Reports.
Point Group Automation. Layer Reports.

"Gene Redmon" wrote in message
news:F087EEE7445DE8F25ACFB6497919BC43@in.WebX.maYIadrTaRb...
> Using VBA in LDT3, what is the best way to convert the angle of a line
from
> Radians to either an Azimuth or Bearing?
>
> TIA, Gene
>
>
Message 3 of 14
Anonymous
in reply to: Anonymous

Thanks for the assistance Bud. I'm trying to format the angle in:

DegreesMinutesSeconds for the Azimuth and Bearings both. If I'm not
mistaking
your suggestion will give me the Azimuth in decimal degrees and I'll need to
convert
that to DDMMSS?

Gene
"Bud Miller" wrote in message
news:3124F28BC0D2BFBAA6B97BD62DFCB768@in.WebX.maYIadrTaRb...
> Off the top of my head you multiply by 180/pi to get the azimuth from
> radians.
>
> Depending on what format you want the output to be in you may need to use:
>
> angletoreal and angletostring for conversion.
>
> If you let me know the desired output I'll send you better instructions.
>
> Bud Miller
> www.BudCAD.com
> Legal Descriptions. Parcel Reports.
> Point Group Automation. Layer Reports.
>
> "Gene Redmon" wrote in message
> news:F087EEE7445DE8F25ACFB6497919BC43@in.WebX.maYIadrTaRb...
> > Using VBA in LDT3, what is the best way to convert the angle of a line
> from
> > Radians to either an Azimuth or Bearing?
> >
> > TIA, Gene
> >
> >
>
>
Message 4 of 14
Anonymous
in reply to: Anonymous

I just stumbled on an almost undocumented "AngleToString" method. I don't know VBA but it's used on the Aecc.Application.ActiveDocument.Utility object...

Sub Example_Utility()
' This example returns the AngleToString value for 0.785398 radians using
' the active document.
Dim doc As AeccDocumen
tSet doc = AeccApplication.ActiveDocument
MsgBox "The setting for AngleToString is " & doc.Utility.AngleToString(0.785398, acDegrees, 4) _
, vbInformation, "Utility Example"
End Sub

Using Visual Lisp, you can see that the acDegree parameter is actual a format designation, and the last paramter is precision....

Command: (setq |aeccapp (vl-catch-all-apply 'vla-getinterfaceobject (list
*acad* "aecc.application")))
#

Command: (setq |aeccdoc (vlax-get |aeccapp "ActiveDocument"))
#

Command: (setq |aeccutil (vlax-get |aeccdoc "Utility"))
#

Command: (vla-angletostring |aeccutil 0.5 0 2)
"28.65"

Command: (vla-angletostring |aeccutil 0.5 0 4)
"28.6479"

Command: (vla-angletostring |aeccutil 0.5 1 4)
"28d38'52\""

Command: (vla-angletostring |aeccutil 0.5 2 4)
"31.8310g"

Command: (vla-angletostring |aeccutil 0.5 3 4)
"0.5000r"

Command: (vla-angletostring |aeccutil 0.5 4 4)
"N 61d21'8\" E"

--
John Uhden, Cadlantic/formerly CADvantage
[ mailto:juhden@cadlantic.com ]
[ http://www.cadlantic.com ]
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711


"Gene Redmon" wrote in message news:F087EEE7445DE8F25ACFB6497919BC43@in.WebX.maYIadrTaRb...
> Using VBA in LDT3, what is the best way to convert the angle of a line from
> Radians to either an Azimuth or Bearing?
>
> TIA, Gene
>
>
Message 5 of 14
Anonymous
in reply to: Anonymous

It's also fairly straight forward if you want to calc it yourself if you
need more control over the string formating. Once you get the decimal degree
value, to get the degree portion of the DMS value you convert the direction
to an integer. This will truncate the numbers to the right of the decimal
point. You then subtract the Deg value from the decimal degree value then
multiple by 60 you get the decimal minutes. then repeat the procedure for
the seconds.

In this example, the original decDeg is a double, the Deg and Min variables
are integers and the Sec variable is a double to carry the seconds
precision.

deg = Int(decDeg)

decDeg= (decDeg- Int(decDeg)) * 60
min = Int(decDeg)

decDeg= (decDeg- Int(decDeg)) * 60
sec = RoundVal(decDeg, 0))

' check for values rounded to 60
If sec >= 60 Then
sec = sec - 60
min = min + 1
End If
If min >= 60 Then
min = min - 60
deg = deg + 1
End If

' format the strings
sDeg = CStr(deg)
If sDeg = "0" Then sDeg = "00" & sDeg
sMin = CStr(min)
If Len(sMin) = 1 Then sMin = "0" & sMin
sSec = CStr(sec)
If Len(sSec) = 1 Then sSec = "0" & sSec

sDMS= sDeg & "-" & sMin & "-" & sSec

This gives the azimuth. If you want bearings you first need to get the
correct quadrant and angle.

Glen

"John Uhden" wrote in message
news:6CCA4AD1BA04E7219FC98360C26B9C2B@in.WebX.maYIadrTaRb...
> I just stumbled on an almost undocumented "AngleToString" method. I don't
know VBA but it's used on the Aecc.Application.ActiveDocument.Utility
object...
>
>
Message 6 of 14
Anonymous
in reply to: Anonymous

Thanks, Glen. We probably all knew that, but my concern was that his interpretation of the angle was w/r/t the drawing's North rotation. I beleive the AngleToString method incorporates that.

So when is Pipeworks going to let me enter inverts in the tabular editor without recalculating the whole d____d run? Did you realize that this June we're coming up on the 10th anniversary of its failure to work correctly?

--
John Uhden, Cadlantic/formerly CADvantage
[ mailto:juhden@cadlantic.com ]
[ http://www.cadlantic.com ]
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711


"Glen Albert" wrote in message news:679F3F890E14A4020B7D36618D84409E@in.WebX.maYIadrTaRb...
> It's also fairly straight forward if you want to calc it yourself if you
> need more control over the string formating. Once you get the decimal degree
> value, to get the degree portion of the DMS value you convert the direction
> to an integer. This will truncate the numbers to the right of the decimal
> point. You then subtract the Deg value from the decimal degree value then
> multiple by 60 you get the decimal minutes. then repeat the procedure for
> the seconds.
>
> In this example, the original decDeg is a double, the Deg and Min variables
> are integers and the Sec variable is a double to carry the seconds
> precision.
>
> deg = Int(decDeg)
>
> decDeg= (decDeg- Int(decDeg)) * 60
> min = Int(decDeg)
>
> decDeg= (decDeg- Int(decDeg)) * 60
> sec = RoundVal(decDeg, 0))
>
> ' check for values rounded to 60
> If sec >= 60 Then
> sec = sec - 60
> min = min + 1
> End If
> If min >= 60 Then
> min = min - 60
> deg = deg + 1
> End If
>
> ' format the strings
> sDeg = CStr(deg)
> If sDeg = "0" Then sDeg = "00" & sDeg
> sMin = CStr(min)
> If Len(sMin) = 1 Then sMin = "0" & sMin
> sSec = CStr(sec)
> If Len(sSec) = 1 Then sSec = "0" & sSec
>
> sDMS= sDeg & "-" & sMin & "-" & sSec
>
> This gives the azimuth. If you want bearings you first need to get the
> correct quadrant and angle.
>
> Glen
>
> "John Uhden" wrote in message
> news:6CCA4AD1BA04E7219FC98360C26B9C2B@in.WebX.maYIadrTaRb...
> > I just stumbled on an almost undocumented "AngleToString" method. I don't
> know VBA but it's used on the Aecc.Application.ActiveDocument.Utility
> object...
> >
> >
>
>
Message 7 of 14
Anonymous
in reply to: Anonymous

This will work with a north rotation of 0 (north straight up).
To use it with NR you'll need to get the angle by converting the XY of the
start and end points to North/East.

unit = acDegreeMinuteSeconds
bearinquest = ent.Angle * (180 / pi)

select case bearinquest
case < 90
bearinquest = Abs(90 - bearinquest)

'similar statements to correct the angle for each quadrant

end select

bearinquest = ActiveDocument.Utility.AngleToReal(bearinquest, acDegrees)
converted = ActiveDocument.Utility.AngleToString(bearinquest, unit, 4)
'convert to min etc

--
Bud Miller
www.BudCAD.com
Try the only Legal Writer that reads parcels directly!

"John Uhden" wrote in message
news:810419FD7A252ED6108C2D18CFF0EFA6@in.WebX.maYIadrTaRb...
> Thanks, Glen. We probably all knew that, but my concern was that his
interpretation of the angle was w/r/t the drawing's North rotation. I
beleive the AngleToString method incorporates that.
>
> So when is Pipeworks going to let me enter inverts in the tabular editor
without recalculating the whole d____d run? Did you realize that this June
we're coming up on the 10th anniversary of its failure to work correctly?
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> [ mailto:juhden@cadlantic.com ]
> [ http://www.cadlantic.com ]
> 2 Village Road
> Sea Girt, NJ 08750
> Tel. 732-974-1711
>
>
> "Glen Albert" wrote in message
news:679F3F890E14A4020B7D36618D84409E@in.WebX.maYIadrTaRb...
> > It's also fairly straight forward if you want to calc it yourself if you
> > need more control over the string formating. Once you get the decimal
degree
> > value, to get the degree portion of the DMS value you convert the
direction
> > to an integer. This will truncate the numbers to the right of the
decimal
> > point. You then subtract the Deg value from the decimal degree value
then
> > multiple by 60 you get the decimal minutes. then repeat the procedure
for
> > the seconds.
> >
> > In this example, the original decDeg is a double, the Deg and Min
variables
> > are integers and the Sec variable is a double to carry the seconds
> > precision.
> >
> > deg = Int(decDeg)
> >
> > decDeg= (decDeg- Int(decDeg)) * 60
> > min = Int(decDeg)
> >
> > decDeg= (decDeg- Int(decDeg)) * 60
> > sec = RoundVal(decDeg, 0))
> >
> > ' check for values rounded to 60
> > If sec >= 60 Then
> > sec = sec - 60
> > min = min + 1
> > End If
> > If min >= 60 Then
> > min = min - 60
> > deg = deg + 1
> > End If
> >
> > ' format the strings
> > sDeg = CStr(deg)
> > If sDeg = "0" Then sDeg = "00" & sDeg
> > sMin = CStr(min)
> > If Len(sMin) = 1 Then sMin = "0" & sMin
> > sSec = CStr(sec)
> > If Len(sSec) = 1 Then sSec = "0" & sSec
> >
> > sDMS= sDeg & "-" & sMin & "-" & sSec
> >
> > This gives the azimuth. If you want bearings you first need to get the
> > correct quadrant and angle.
> >
> > Glen
> >
> > "John Uhden" wrote in message
> > news:6CCA4AD1BA04E7219FC98360C26B9C2B@in.WebX.maYIadrTaRb...
> > > I just stumbled on an almost undocumented "AngleToString" method. I
don't
> > know VBA but it's used on the Aecc.Application.ActiveDocument.Utility
> > object...
> > >
> > >
> >
> >
Message 8 of 14
Anonymous
in reply to: Anonymous

Well, whadoyaknow. Seems like a pretty useless function relative to the Utility object. Thanks for the info, Bud.

BTW, do you have any documentation on the dxf values in the "AEC_VARS_DWG_SETUP" dictionary?

--
John Uhden, Cadlantic/formerly CADvantage
[ mailto:juhden@cadlantic.com ]
[ http://www.cadlantic.com ]
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711


"Bud" wrote in message news:CCFAF8FF20879105FFED13D7A4864586@in.WebX.maYIadrTaRb...
> This will work with a north rotation of 0 (north straight up).
> To use it with NR you'll need to get the angle by converting the XY of the
> start and end points to North/East.
>
> unit = acDegreeMinuteSeconds
> bearinquest = ent.Angle * (180 / pi)
>
> select case bearinquest
> case < 90
> bearinquest = Abs(90 - bearinquest)
>
> 'similar statements to correct the angle for each quadrant
>
> end select
>
> bearinquest = ActiveDocument.Utility.AngleToReal(bearinquest, acDegrees)
> converted = ActiveDocument.Utility.AngleToString(bearinquest, unit, 4)
> 'convert to min etc
>
> --
> Bud Miller
> www.BudCAD.com
> Try the only Legal Writer that reads parcels directly!
>
> "John Uhden" wrote in message
> news:810419FD7A252ED6108C2D18CFF0EFA6@in.WebX.maYIadrTaRb...
> > Thanks, Glen. We probably all knew that, but my concern was that his
> interpretation of the angle was w/r/t the drawing's North rotation. I
> beleive the AngleToString method incorporates that.
> >
> > So when is Pipeworks going to let me enter inverts in the tabular editor
> without recalculating the whole d____d run? Did you realize that this June
> we're coming up on the 10th anniversary of its failure to work correctly?
> >
> > --
> > John Uhden, Cadlantic/formerly CADvantage
> > [ mailto:juhden@cadlantic.com ]
> > [ http://www.cadlantic.com ]
> > 2 Village Road
> > Sea Girt, NJ 08750
> > Tel. 732-974-1711
> >
> >
> > "Glen Albert" wrote in message
> news:679F3F890E14A4020B7D36618D84409E@in.WebX.maYIadrTaRb...
> > > It's also fairly straight forward if you want to calc it yourself if you
> > > need more control over the string formating. Once you get the decimal
> degree
> > > value, to get the degree portion of the DMS value you convert the
> direction
> > > to an integer. This will truncate the numbers to the right of the
> decimal
> > > point. You then subtract the Deg value from the decimal degree value
> then
> > > multiple by 60 you get the decimal minutes. then repeat the procedure
> for
> > > the seconds.
> > >
> > > In this example, the original decDeg is a double, the Deg and Min
> variables
> > > are integers and the Sec variable is a double to carry the seconds
> > > precision.
> > >
> > > deg = Int(decDeg)
> > >
> > > decDeg= (decDeg- Int(decDeg)) * 60
> > > min = Int(decDeg)
> > >
> > > decDeg= (decDeg- Int(decDeg)) * 60
> > > sec = RoundVal(decDeg, 0))
> > >
> > > ' check for values rounded to 60
> > > If sec >= 60 Then
> > > sec = sec - 60
> > > min = min + 1
> > > End If
> > > If min >= 60 Then
> > > min = min - 60
> > > deg = deg + 1
> > > End If
> > >
> > > ' format the strings
> > > sDeg = CStr(deg)
> > > If sDeg = "0" Then sDeg = "00" & sDeg
> > > sMin = CStr(min)
> > > If Len(sMin) = 1 Then sMin = "0" & sMin
> > > sSec = CStr(sec)
> > > If Len(sSec) = 1 Then sSec = "0" & sSec
> > >
> > > sDMS= sDeg & "-" & sMin & "-" & sSec
> > >
> > > This gives the azimuth. If you want bearings you first need to get the
> > > correct quadrant and angle.
> > >
> > > Glen
> > >
> > > "John Uhden" wrote in message
> > > news:6CCA4AD1BA04E7219FC98360C26B9C2B@in.WebX.maYIadrTaRb...
> > > > I just stumbled on an almost undocumented "AngleToString" method. I
> don't
> > > know VBA but it's used on the Aecc.Application.ActiveDocument.Utility
> > > object...
> > > >
> > > >
> > >
> > >
>
>
Message 9 of 14
Anonymous
in reply to: Anonymous

This will get you the bearing (without a direction) from a selected line
when the drawing is north rotated:
(To get the direction you'd need to add a case statement that checks the N/E
of the start and endpoints relative to each other.)

Dim util As AeccUtility
Set util = AeccApplication.ActiveDocument.Utility

Dim var1 As Variant
Dim var2 As Variant

ptXY = ent.StartPoint
ptXY2 = ent.EndPoint

' Convert point to Easting, Northing
var1 = util.XyToEastNorth(ptXY)
var2 = util.XyToEastNorth(ptXY2)

opp = Abs(var1(0) - var2(0))
adj = Abs(var1(1) - var2(1))
dratio = opp / adj
newbearing = Atn(dratio) 'inverse tangent

Bud Miller
www.BudCAD.com
Try the only Legal Writer that reads parcels directly!


"Bud" wrote in message
news:CCFAF8FF20879105FFED13D7A4864586@in.WebX.maYIadrTaRb...
> This will work with a north rotation of 0 (north straight up).
> To use it with NR you'll need to get the angle by converting the XY of the
> start and end points to North/East.
>
> unit = acDegreeMinuteSeconds
> bearinquest = ent.Angle * (180 / pi)
>
> select case bearinquest
> case < 90
> bearinquest = Abs(90 - bearinquest)
>
> 'similar statements to correct the angle for each quadrant
>
> end select
>
> bearinquest = ActiveDocument.Utility.AngleToReal(bearinquest, acDegrees)
> converted = ActiveDocument.Utility.AngleToString(bearinquest, unit, 4)
> 'convert to min etc
>
> --
> Bud Miller
> www.BudCAD.com
> Try the only Legal Writer that reads parcels directly!
>
> "John Uhden" wrote in message
> news:810419FD7A252ED6108C2D18CFF0EFA6@in.WebX.maYIadrTaRb...
> > Thanks, Glen. We probably all knew that, but my concern was that his
> interpretation of the angle was w/r/t the drawing's North rotation. I
> beleive the AngleToString method incorporates that.
> >
> > So when is Pipeworks going to let me enter inverts in the tabular editor
> without recalculating the whole d____d run? Did you realize that this
June
> we're coming up on the 10th anniversary of its failure to work correctly?
> >
> > --
> > John Uhden, Cadlantic/formerly CADvantage
> > [ mailto:juhden@cadlantic.com ]
> > [ http://www.cadlantic.com ]
> > 2 Village Road
> > Sea Girt, NJ 08750
> > Tel. 732-974-1711
> >
> >
> > "Glen Albert" wrote in message
> news:679F3F890E14A4020B7D36618D84409E@in.WebX.maYIadrTaRb...
> > > It's also fairly straight forward if you want to calc it yourself if
you
> > > need more control over the string formating. Once you get the decimal
> degree
> > > value, to get the degree portion of the DMS value you convert the
> direction
> > > to an integer. This will truncate the numbers to the right of the
> decimal
> > > point. You then subtract the Deg value from the decimal degree value
> then
> > > multiple by 60 you get the decimal minutes. then repeat the procedure
> for
> > > the seconds.
> > >
> > > In this example, the original decDeg is a double, the Deg and Min
> variables
> > > are integers and the Sec variable is a double to carry the seconds
> > > precision.
> > >
> > > deg = Int(decDeg)
> > >
> > > decDeg= (decDeg- Int(decDeg)) * 60
> > > min = Int(decDeg)
> > >
> > > decDeg= (decDeg- Int(decDeg)) * 60
> > > sec = RoundVal(decDeg, 0))
> > >
> > > ' check for values rounded to 60
> > > If sec >= 60 Then
> > > sec = sec - 60
> > > min = min + 1
> > > End If
> > > If min >= 60 Then
> > > min = min - 60
> > > deg = deg + 1
> > > End If
> > >
> > > ' format the strings
> > > sDeg = CStr(deg)
> > > If sDeg = "0" Then sDeg = "00" & sDeg
> > > sMin = CStr(min)
> > > If Len(sMin) = 1 Then sMin = "0" & sMin
> > > sSec = CStr(sec)
> > > If Len(sSec) = 1 Then sSec = "0" & sSec
> > >
> > > sDMS= sDeg & "-" & sMin & "-" & sSec
> > >
> > > This gives the azimuth. If you want bearings you first need to get the
> > > correct quadrant and angle.
> > >
> > > Glen
> > >
> > > "John Uhden" wrote in message
> > > news:6CCA4AD1BA04E7219FC98360C26B9C2B@in.WebX.maYIadrTaRb...
> > > > I just stumbled on an almost undocumented "AngleToString" method. I
> don't
> > > know VBA but it's used on the Aecc.Application.ActiveDocument.Utility
> > > object...
> > > >
> > > >
> > >
> > >
>
>
Message 10 of 14
Anonymous
in reply to: Anonymous

Thanks to everyone that responded. You all provided many solutions that
product
great results.

One other thing I'm stuggling with is, once I get these string values I'm
writing them to a text file.
Of course, since they are Strings they are entered into the text file with
quotes around them. "String"
Is there anyway to prevent the quotes from being placed in the text file?

Gene
"Bud" wrote in message
news:2EC6ED4834D30BBB422B56C4EFE37668@in.WebX.maYIadrTaRb...
> This will get you the bearing (without a direction) from a selected line
> when the drawing is north rotated:
> (To get the direction you'd need to add a case statement that checks the
N/E
> of the start and endpoints relative to each other.)
>
> Dim util As AeccUtility
> Set util = AeccApplication.ActiveDocument.Utility
>
> Dim var1 As Variant
> Dim var2 As Variant
>
> ptXY = ent.StartPoint
> ptXY2 = ent.EndPoint
>
> ' Convert point to Easting, Northing
> var1 = util.XyToEastNorth(ptXY)
> var2 = util.XyToEastNorth(ptXY2)
>
> opp = Abs(var1(0) - var2(0))
> adj = Abs(var1(1) - var2(1))
> dratio = opp / adj
> newbearing = Atn(dratio) 'inverse tangent
>
> Bud Miller
> www.BudCAD.com
> Try the only Legal Writer that reads parcels directly!
>
>
> "Bud" wrote in message
> news:CCFAF8FF20879105FFED13D7A4864586@in.WebX.maYIadrTaRb...
> > This will work with a north rotation of 0 (north straight up).
> > To use it with NR you'll need to get the angle by converting the XY of
the
> > start and end points to North/East.
> >
> > unit = acDegreeMinuteSeconds
> > bearinquest = ent.Angle * (180 / pi)
> >
> > select case bearinquest
> > case < 90
> > bearinquest = Abs(90 - bearinquest)
> >
> > 'similar statements to correct the angle for each quadrant
> >
> > end select
> >
> > bearinquest = ActiveDocument.Utility.AngleToReal(bearinquest, acDegrees)
> > converted = ActiveDocument.Utility.AngleToString(bearinquest, unit, 4)
> > 'convert to min etc
> >
> > --
> > Bud Miller
> > www.BudCAD.com
> > Try the only Legal Writer that reads parcels directly!
> >
> > "John Uhden" wrote in message
> > news:810419FD7A252ED6108C2D18CFF0EFA6@in.WebX.maYIadrTaRb...
> > > Thanks, Glen. We probably all knew that, but my concern was that his
> > interpretation of the angle was w/r/t the drawing's North rotation. I
> > beleive the AngleToString method incorporates that.
> > >
> > > So when is Pipeworks going to let me enter inverts in the tabular
editor
> > without recalculating the whole d____d run? Did you realize that this
> June
> > we're coming up on the 10th anniversary of its failure to work
correctly?
> > >
> > > --
> > > John Uhden, Cadlantic/formerly CADvantage
> > > [ mailto:juhden@cadlantic.com ]
> > > [ http://www.cadlantic.com ]
> > > 2 Village Road
> > > Sea Girt, NJ 08750
> > > Tel. 732-974-1711
> > >
> > >
> > > "Glen Albert" wrote in message
> > news:679F3F890E14A4020B7D36618D84409E@in.WebX.maYIadrTaRb...
> > > > It's also fairly straight forward if you want to calc it yourself if
> you
> > > > need more control over the string formating. Once you get the
decimal
> > degree
> > > > value, to get the degree portion of the DMS value you convert the
> > direction
> > > > to an integer. This will truncate the numbers to the right of the
> > decimal
> > > > point. You then subtract the Deg value from the decimal degree value
> > then
> > > > multiple by 60 you get the decimal minutes. then repeat the
procedure
> > for
> > > > the seconds.
> > > >
> > > > In this example, the original decDeg is a double, the Deg and Min
> > variables
> > > > are integers and the Sec variable is a double to carry the seconds
> > > > precision.
> > > >
> > > > deg = Int(decDeg)
> > > >
> > > > decDeg= (decDeg- Int(decDeg)) * 60
> > > > min = Int(decDeg)
> > > >
> > > > decDeg= (decDeg- Int(decDeg)) * 60
> > > > sec = RoundVal(decDeg, 0))
> > > >
> > > > ' check for values rounded to 60
> > > > If sec >= 60 Then
> > > > sec = sec - 60
> > > > min = min + 1
> > > > End If
> > > > If min >= 60 Then
> > > > min = min - 60
> > > > deg = deg + 1
> > > > End If
> > > >
> > > > ' format the strings
> > > > sDeg = CStr(deg)
> > > > If sDeg = "0" Then sDeg = "00" & sDeg
> > > > sMin = CStr(min)
> > > > If Len(sMin) = 1 Then sMin = "0" & sMin
> > > > sSec = CStr(sec)
> > > > If Len(sSec) = 1 Then sSec = "0" & sSec
> > > >
> > > > sDMS= sDeg & "-" & sMin & "-" & sSec
> > > >
> > > > This gives the azimuth. If you want bearings you first need to get
the
> > > > correct quadrant and angle.
> > > >
> > > > Glen
> > > >
> > > > "John Uhden" wrote in message
> > > > news:6CCA4AD1BA04E7219FC98360C26B9C2B@in.WebX.maYIadrTaRb...
> > > > > I just stumbled on an almost undocumented "AngleToString" method.
I
> > don't
> > > > know VBA but it's used on the
Aecc.Application.ActiveDocument.Utility
> > > > object...
> > > > >
> > > > >
> > > >
> > > >
> >
> >
>
>
Message 11 of 14
Anonymous
in reply to: Anonymous

Hi John,

> BTW, do you have any documentation on the dxf values in the
"AEC_VARS_DWG_SETUP" dictionary?

Sorry I'm not familiar with those.

Bud Miller
www.BudCAD.com
Try the only Legal Writer that reads parcels directly!


"John Uhden" wrote in message
news:855B59143D3E5B450BBBA056414E8A3E@in.WebX.maYIadrTaRb...
> Well, whadoyaknow. Seems like a pretty useless function relative to the
Utility object. Thanks for the info, Bud.
>
> BTW, do you have any documentation on the dxf values in the
"AEC_VARS_DWG_SETUP" dictionary?
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> [ mailto:juhden@cadlantic.com ]
> [ http://www.cadlantic.com ]
> 2 Village Road
> Sea Girt, NJ 08750
> Tel. 732-974-1711
>
>
> "Bud" wrote in message
news:CCFAF8FF20879105FFED13D7A4864586@in.WebX.maYIadrTaRb...
> > This will work with a north rotation of 0 (north straight up).
> > To use it with NR you'll need to get the angle by converting the XY of
the
> > start and end points to North/East.
> >
> > unit = acDegreeMinuteSeconds
> > bearinquest = ent.Angle * (180 / pi)
> >
> > select case bearinquest
> > case < 90
> > bearinquest = Abs(90 - bearinquest)
> >
> > 'similar statements to correct the angle for each quadrant
> >
> > end select
> >
> > bearinquest = ActiveDocument.Utility.AngleToReal(bearinquest, acDegrees)
> > converted = ActiveDocument.Utility.AngleToString(bearinquest, unit, 4)
> > 'convert to min etc
> >
> > --
> > Bud Miller
> > www.BudCAD.com
> > Try the only Legal Writer that reads parcels directly!
> >
> > "John Uhden" wrote in message
> > news:810419FD7A252ED6108C2D18CFF0EFA6@in.WebX.maYIadrTaRb...
> > > Thanks, Glen. We probably all knew that, but my concern was that his
> > interpretation of the angle was w/r/t the drawing's North rotation. I
> > beleive the AngleToString method incorporates that.
> > >
> > > So when is Pipeworks going to let me enter inverts in the tabular
editor
> > without recalculating the whole d____d run? Did you realize that this
June
> > we're coming up on the 10th anniversary of its failure to work
correctly?
> > >
> > > --
> > > John Uhden, Cadlantic/formerly CADvantage
> > > [ mailto:juhden@cadlantic.com ]
> > > [ http://www.cadlantic.com ]
> > > 2 Village Road
> > > Sea Girt, NJ 08750
> > > Tel. 732-974-1711
> > >
> > >
> > > "Glen Albert" wrote in message
> > news:679F3F890E14A4020B7D36618D84409E@in.WebX.maYIadrTaRb...
> > > > It's also fairly straight forward if you want to calc it yourself if
you
> > > > need more control over the string formating. Once you get the
decimal
> > degree
> > > > value, to get the degree portion of the DMS value you convert the
> > direction
> > > > to an integer. This will truncate the numbers to the right of the
> > decimal
> > > > point. You then subtract the Deg value from the decimal degree value
> > then
> > > > multiple by 60 you get the decimal minutes. then repeat the
procedure
> > for
> > > > the seconds.
> > > >
> > > > In this example, the original decDeg is a double, the Deg and Min
> > variables
> > > > are integers and the Sec variable is a double to carry the seconds
> > > > precision.
> > > >
> > > > deg = Int(decDeg)
> > > >
> > > > decDeg= (decDeg- Int(decDeg)) * 60
> > > > min = Int(decDeg)
> > > >
> > > > decDeg= (decDeg- Int(decDeg)) * 60
> > > > sec = RoundVal(decDeg, 0))
> > > >
> > > > ' check for values rounded to 60
> > > > If sec >= 60 Then
> > > > sec = sec - 60
> > > > min = min + 1
> > > > End If
> > > > If min >= 60 Then
> > > > min = min - 60
> > > > deg = deg + 1
> > > > End If
> > > >
> > > > ' format the strings
> > > > sDeg = CStr(deg)
> > > > If sDeg = "0" Then sDeg = "00" & sDeg
> > > > sMin = CStr(min)
> > > > If Len(sMin) = 1 Then sMin = "0" & sMin
> > > > sSec = CStr(sec)
> > > > If Len(sSec) = 1 Then sSec = "0" & sSec
> > > >
> > > > sDMS= sDeg & "-" & sMin & "-" & sSec
> > > >
> > > > This gives the azimuth. If you want bearings you first need to get
the
> > > > correct quadrant and angle.
> > > >
> > > > Glen
> > > >
> > > > "John Uhden" wrote in message
> > > > news:6CCA4AD1BA04E7219FC98360C26B9C2B@in.WebX.maYIadrTaRb...
> > > > > I just stumbled on an almost undocumented "AngleToString" method.
I
> > don't
> > > > know VBA but it's used on the
Aecc.Application.ActiveDocument.Utility
> > > > object...
> > > > >
> > > > >
> > > >
> > > >
> >
> >
Message 12 of 14
Anonymous
in reply to: Anonymous

Hmmm ... if you want additional control over the string you may need to do
what Glen had in his first response. His idea would add leading zeros and
you can leave out the quotes. I don't like the fact that
Utility.AngleToString sub does not leave leading zeros ... don't ask me why.

Andy
Message 13 of 14
Anonymous
in reply to: Anonymous

If I've got dwg x,y coords, I first convert to n/e before calc'ing the
direction to account for the north rotation. I'm not involved with pipeworks
so I can't help you there.

Glen


"John Uhden" wrote in message
news:810419FD7A252ED6108C2D18CFF0EFA6@in.WebX.maYIadrTaRb...
> Thanks, Glen. We probably all knew that, but my concern was that his
interpretation of the angle was w/r/t the drawing's North rotation. I
beleive the AngleToString method incorporates that.
>
> So when is Pipeworks going to let me enter inverts in the tabular editor
without recalculating the whole d____d run? Did you realize that this June
we're coming up on the 10th anniversary of its failure to work correctly?
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> [ mailto:juhden@cadlantic.com ]
> [ http://www.cadlantic.com ]
> 2 Village Road
> Sea Girt, NJ 08750
> Tel. 732-974-1711
>
>
> "Glen Albert" wrote in message
news:679F3F890E14A4020B7D36618D84409E@in.WebX.maYIadrTaRb...
> > It's also fairly straight forward if you want to calc it yourself if you
> > need more control over the string formating. Once you get the decimal
degree
> > value, to get the degree portion of the DMS value you convert the
direction
> > to an integer. This will truncate the numbers to the right of the
decimal
> > point. You then subtract the Deg value from the decimal degree value
then
> > multiple by 60 you get the decimal minutes. then repeat the procedure
for
> > the seconds.
> >
> > In this example, the original decDeg is a double, the Deg and Min
variables
> > are integers and the Sec variable is a double to carry the seconds
> > precision.
> >
> > deg = Int(decDeg)
> >
> > decDeg= (decDeg- Int(decDeg)) * 60
> > min = Int(decDeg)
> >
> > decDeg= (decDeg- Int(decDeg)) * 60
> > sec = RoundVal(decDeg, 0))
> >
> > ' check for values rounded to 60
> > If sec >= 60 Then
> > sec = sec - 60
> > min = min + 1
> > End If
> > If min >= 60 Then
> > min = min - 60
> > deg = deg + 1
> > End If
> >
> > ' format the strings
> > sDeg = CStr(deg)
> > If sDeg = "0" Then sDeg = "00" & sDeg
> > sMin = CStr(min)
> > If Len(sMin) = 1 Then sMin = "0" & sMin
> > sSec = CStr(sec)
> > If Len(sSec) = 1 Then sSec = "0" & sSec
> >
> > sDMS= sDeg & "-" & sMin & "-" & sSec
> >
> > This gives the azimuth. If you want bearings you first need to get the
> > correct quadrant and angle.
> >
> > Glen
> >
> > "John Uhden" wrote in message
> > news:6CCA4AD1BA04E7219FC98360C26B9C2B@in.WebX.maYIadrTaRb...
> > > I just stumbled on an almost undocumented "AngleToString" method. I
don't
> > know VBA but it's used on the Aecc.Application.ActiveDocument.Utility
> > object...
> > >
> > >
> >
> >
Message 14 of 14
Anonymous
in reply to: Anonymous

Hi Gene,

If you "Print" to a file the quote marks are left off.
If you "Write" to a file the quote marks are left in.

--


Laurie Comerford
CADApps
www.cadapps.com.au

"Gene Redmon" wrote in message
news:507EC0890283C4BF52B9463FF036626E@in.WebX.maYIadrTaRb...
> Thanks to everyone that responded. You all provided many solutions that
> product
> great results.
>
> One other thing I'm stuggling with is, once I get these string values I'm
> writing them to a text file.
> Of course, since they are Strings they are entered into the text file with
> quotes around them. "String"
> Is there anyway to prevent the quotes from being placed in the text file?
>
> Gene
> "Bud" wrote in message
> news:2EC6ED4834D30BBB422B56C4EFE37668@in.WebX.maYIadrTaRb...
> > This will get you the bearing (without a direction) from a selected line
> > when the drawing is north rotated:
> > (To get the direction you'd need to add a case statement that checks the
> N/E
> > of the start and endpoints relative to each other.)
> >
> > Dim util As AeccUtility
> > Set util = AeccApplication.ActiveDocument.Utility
> >
> > Dim var1 As Variant
> > Dim var2 As Variant
> >
> > ptXY = ent.StartPoint
> > ptXY2 = ent.EndPoint
> >
> > ' Convert point to Easting, Northing
> > var1 = util.XyToEastNorth(ptXY)
> > var2 = util.XyToEastNorth(ptXY2)
> >
> > opp = Abs(var1(0) - var2(0))
> > adj = Abs(var1(1) - var2(1))
> > dratio = opp / adj
> > newbearing = Atn(dratio) 'inverse tangent
> >
> > Bud Miller
> > www.BudCAD.com
> > Try the only Legal Writer that reads parcels directly!
> >
> >
> > "Bud" wrote in message
> > news:CCFAF8FF20879105FFED13D7A4864586@in.WebX.maYIadrTaRb...
> > > This will work with a north rotation of 0 (north straight up).
> > > To use it with NR you'll need to get the angle by converting the XY of
> the
> > > start and end points to North/East.
> > >
> > > unit = acDegreeMinuteSeconds
> > > bearinquest = ent.Angle * (180 / pi)
> > >
> > > select case bearinquest
> > > case < 90
> > > bearinquest = Abs(90 - bearinquest)
> > >
> > > 'similar statements to correct the angle for each quadrant
> > >
> > > end select
> > >
> > > bearinquest = ActiveDocument.Utility.AngleToReal(bearinquest,
acDegrees)
> > > converted = ActiveDocument.Utility.AngleToString(bearinquest, unit, 4)
> > > 'convert to min etc
> > >
> > > --
> > > Bud Miller
> > > www.BudCAD.com
> > > Try the only Legal Writer that reads parcels directly!
> > >
> > > "John Uhden" wrote in message
> > > news:810419FD7A252ED6108C2D18CFF0EFA6@in.WebX.maYIadrTaRb...
> > > > Thanks, Glen. We probably all knew that, but my concern was that
his
> > > interpretation of the angle was w/r/t the drawing's North rotation. I
> > > beleive the AngleToString method incorporates that.
> > > >
> > > > So when is Pipeworks going to let me enter inverts in the tabular
> editor
> > > without recalculating the whole d____d run? Did you realize that this
> > June
> > > we're coming up on the 10th anniversary of its failure to work
> correctly?
> > > >
> > > > --
> > > > John Uhden, Cadlantic/formerly CADvantage
> > > > [ mailto:juhden@cadlantic.com ]
> > > > [ http://www.cadlantic.com ]
> > > > 2 Village Road
> > > > Sea Girt, NJ 08750
> > > > Tel. 732-974-1711
> > > >
> > > >
> > > > "Glen Albert" wrote in message
> > > news:679F3F890E14A4020B7D36618D84409E@in.WebX.maYIadrTaRb...
> > > > > It's also fairly straight forward if you want to calc it yourself
if
> > you
> > > > > need more control over the string formating. Once you get the
> decimal
> > > degree
> > > > > value, to get the degree portion of the DMS value you convert the
> > > direction
> > > > > to an integer. This will truncate the numbers to the right of the
> > > decimal
> > > > > point. You then subtract the Deg value from the decimal degree
value
> > > then
> > > > > multiple by 60 you get the decimal minutes. then repeat the
> procedure
> > > for
> > > > > the seconds.
> > > > >
> > > > > In this example, the original decDeg is a double, the Deg and Min
> > > variables
> > > > > are integers and the Sec variable is a double to carry the seconds
> > > > > precision.
> > > > >
> > > > > deg = Int(decDeg)
> > > > >
> > > > > decDeg= (decDeg- Int(decDeg)) * 60
> > > > > min = Int(decDeg)
> > > > >
> > > > > decDeg= (decDeg- Int(decDeg)) * 60
> > > > > sec = RoundVal(decDeg, 0))
> > > > >
> > > > > ' check for values rounded to 60
> > > > > If sec >= 60 Then
> > > > > sec = sec - 60
> > > > > min = min + 1
> > > > > End If
> > > > > If min >= 60 Then
> > > > > min = min - 60
> > > > > deg = deg + 1
> > > > > End If
> > > > >
> > > > > ' format the strings
> > > > > sDeg = CStr(deg)
> > > > > If sDeg = "0" Then sDeg = "00" & sDeg
> > > > > sMin = CStr(min)
> > > > > If Len(sMin) = 1 Then sMin = "0" & sMin
> > > > > sSec = CStr(sec)
> > > > > If Len(sSec) = 1 Then sSec = "0" & sSec
> > > > >
> > > > > sDMS= sDeg & "-" & sMin & "-" & sSec
> > > > >
> > > > > This gives the azimuth. If you want bearings you first need to get
> the
> > > > > correct quadrant and angle.
> > > > >
> > > > > Glen
> > > > >
> > > > > "John Uhden" wrote in message
> > > > > news:6CCA4AD1BA04E7219FC98360C26B9C2B@in.WebX.maYIadrTaRb...
> > > > > > I just stumbled on an almost undocumented "AngleToString"
method.
> I
> > > don't
> > > > > know VBA but it's used on the
> Aecc.Application.ActiveDocument.Utility
> > > > > object...
> > > > > >
> > > > > >
> > > > >
> > > > >
> > >
> > >
> >
> >
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report