Author Topic: Seconds issue  (Read 4751 times)

0 Members and 1 Guest are viewing this topic.

Matersammichman

  • Guest
Seconds issue
« on: September 26, 2008, 04:07:07 PM »
Okay, I'm stumped.
How can I string together "seconds" as in Degrees Minutes Seconds, in a command?
When I try to string it as """, it adds an extra " ("""")
If I do it as two minute marks ('), it's not recognizable to Cad.
I've tried lots of variations to no avail.
fyi- this is for drawing a Civil Bearing as in,

@244<120DN15'44"W

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Seconds issue
« Reply #1 on: September 26, 2008, 04:08:02 PM »
Can you post what you've got so far?
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Matersammichman

  • Guest
Re: Seconds issue
« Reply #2 on: September 26, 2008, 04:11:17 PM »
Here ya go...

Private Sub cmdAddLine_Click()
If Label1.Caption = "" Then
Label1.Caption = "@" & Val(txtboxDistance.text) & "<" & lblStartDir.Caption & Val(txtboxDegrees.text) & "D" & Val(txtboxMinutes.text) & "'" & Val(txtboxSeconds.text) & vbCr & lblEndDir.Caption
Else
End If

ListBox1.AddItem Label1.Caption
txtboxDistance.text = ""
txtboxDegrees.text = ""
txtboxMinutes.text = ""
txtboxSeconds.text = ""
optClear1.value = True
optClear2.value = True
Label1.Caption = ""

End Sub

Private Sub cmdStringInfoTogether_Click()
On Error Resume Next
ThisDrawing.SendCommand "line" & vbCr & "0,0,0" & vbCr & ListBox1.List(0)
End Sub

Matersammichman

  • Guest
Re: Seconds issue
« Reply #3 on: September 26, 2008, 04:12:39 PM »
Naturally, values are added first for,

txtboxDistance.text
txtboxDegrees.text
txtboxMinutes.text
txtboxSeconds.text

Matersammichman

  • Guest
Re: Seconds issue
« Reply #4 on: September 26, 2008, 04:14:07 PM »
...plus the Radio Button data selection for start and end directions (NSEW).

Cathy

  • Guest
Re: Seconds issue
« Reply #5 on: September 26, 2008, 04:17:52 PM »
I have used something like this in the past. 
Private Const quote     As String = """"
Label1.Caption = "@" & Val(txtboxDistance.text) & "<" & lblStartDir.Caption & Val(txtboxDegrees.text) & "D" & Val(txtboxMinutes.text) & "'" & Val(txtboxSeconds.text) & quote & vbCr & lblEndDir.Caption

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Seconds issue
« Reply #6 on: September 26, 2008, 04:22:27 PM »
THis little test worked for me....

ThisDrawing.SendCommand "line" & vbCr & "0,0,0" & vbCr & "@244<N30D15'44""W" & vbCr & vbCr

Matersammichman

  • Guest
Re: Seconds issue
« Reply #7 on: September 26, 2008, 04:27:16 PM »
Right Jeff, but since I can't know ahead of time what the seconds are, or what the end direction is, I can't compile it like that. It has be strung on-the-fly.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Seconds issue
« Reply #8 on: September 26, 2008, 04:29:18 PM »
Not to harp on using send command, but what if you took the 3 text box values, did the math, converted to radians (which is what autocad wants) and draw the line that way?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Seconds issue
« Reply #9 on: September 26, 2008, 04:30:10 PM »
Yeah, I realized that as I was posting.....see Cathy's response....or Duh's

Matersammichman

  • Guest
Re: Seconds issue
« Reply #10 on: September 26, 2008, 04:32:58 PM »
Duh....
Enlighten me on the best way to perform the task. Code?
I don't have to convert or draw Civil very often.
In fact, I'm doing this so that I don't have to remember all of the symbology on future projects.
I'm getting older, and remembering every last detail of VBA and CAD is getting more challenging by the day, LOL.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Seconds issue
« Reply #11 on: September 26, 2008, 05:13:09 PM »
Here's a quickie that will convert Surveyor DMS to Acad Radians. The arguments you need to pass are:
Direction Quadrant in the form of an Integer, where NE = 1, SE = 2, SW = 3, and NW = 4
DD as a Double .... use the converter CDbl(txtbox.value)
MM as a Double ....ditto
SS as a Double ....ditto
Code: [Select]
Function NEWS2Rads(iDir As Integer, dd As Double, mm As Double, ss As Double) As Double
Dim decDeg As Double
decDeg = ss / 60#
decDeg = (mm + decDeg) / 60#
decDeg = dd + decDeg

Dim pi As Double
Dim radDeg As Double
pi = Atn(1) * 4
radDeg = pi * (decDeg / 180#)

Select Case iDir
    Case Is = 1 'NorthEast
        NEWS2Rads = (pi * 0.5) - radDeg
    Case Is = 2 'SouthEast
        NEWS2Rads = (pi * 1.5) + radDeg
    Case Is = 3 'SouthWest
        NEWS2Rads = (pi * 1.5) - radDeg
    Case Else   'NorthWest
        NEWS2Rads = (pi * 0.5) + radDeg
End Select
       
End Function

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Seconds issue
« Reply #12 on: September 29, 2008, 01:27:38 AM »
thanks Jeff.  I haven't been at a computer all weekend and that was what I was thinking.  I will go through my stuff tomorrow at work and see if I can post any other examples.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Seconds issue
« Reply #13 on: September 29, 2008, 03:38:45 AM »
no escape char's in vb??

eg  str = value & "\""

just a thought....
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Seconds issue
« Reply #14 on: September 29, 2008, 10:47:40 AM »
For clarification sake, would it be clearer to show ss as the number divided by 3600, with minutes divided by 60, and add these to degrees all at once.  The reason I ask is I was re-reading through the code, and saw the seconds being divided by 60 twice, and thought "thats not right", but after thinking about it more, it is right.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)