Author Topic: New Project Step 1 Linetypes  (Read 16051 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #30 on: July 11, 2005, 09:52:05 AM »
Im back, and things are better than we had first heard.  I'll leave it at that so we dont completely HiJack this thread
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)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #31 on: July 11, 2005, 11:05:17 AM »
So did anyone think about code over the weekend?  Was anyone able to come up with some error checking based on error number using Select Case?
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)

daron

  • Guest
New Project Step 1 Linetypes
« Reply #32 on: July 11, 2005, 11:14:21 AM »
Not me, sir. I helped with an eagle scout service project that wiped me out. I never slept so much as I have this past weekend.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #33 on: July 11, 2005, 11:19:08 AM »
Had to come back to work to get some rest?  Been there and done that.
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)

daron

  • Guest
New Project Step 1 Linetypes
« Reply #34 on: July 11, 2005, 11:31:53 AM »
No, the project lasted from 8am to noon. When I got home I went to sleep. Sunday after church, I went to sleep again and no, I didn't fall asleep at church. Trying to keep kids quiet and still will keep you plenty active and awake. Anyway, let's get this back on track:


Get to those error traps. Good idea to introduce them early, Dave.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #35 on: July 11, 2005, 11:38:26 AM »
Based on This Post does anyone have an idea of how we can trap for errors in loading linetypes?
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)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #36 on: July 12, 2005, 10:40:56 AM »
OK, so anyone have any ideas?
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)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #37 on: July 12, 2005, 11:13:39 AM »
Given the example I posted earlier,
Code: [Select]
Dim A as interger
A=3

Select Case A

Case 1:
Msgbox "A = 1"

Case 2:
Msgbox "A = 2"

Case 3:
Msgbox "A = 3"

Case Else:
Msgbox "A is not in the List"
End Select


Lets look at what is going on in this code.  First I have to create the variable, A, so Dim A as integer.
Im using an integer just as an example.  Then Set A=3.  So everyone agrees A=3 right?  OK, now the
Select Case statement.

Select Case A - which means, evaluate A, and see if it matches any of the choices that follow.

Case 1:   - which means Does A=1?  No, so go to next case.
Case 2:    Does A=2?  No, go to next case
Case 3:     Does A=3?  Yes, so do what follows which is a messagebox that says A=3

Had A not equaled 1, 2, or 3, the Case Else: would have been used as a catch all,  w/ a box that said A is not in list.

Now how could we use that logic and trap an error for loading a linetype?

Code: [Select]
Public Sub LLINE()
On Error GoTo ErrorHandler
. . . . .
End Sub


We start by telling the code to GoTo the ErrorHandler if there is a problem.  Following this, we can begin coding our app.
At some point, we put in the error handler

Code: [Select]
Public Sub LLINE()
On Error GoTo ErrorHandler
ThisDrawing.Linetypes.Load "HIDDEN", "ACAD.LIN"
ThisDrawing.Linetypes.Load "DASHED", "ACAD.LIN"
Exit Sub

ErrorHandler:
. . . . . .
End Sub

OK, so we have told Vb to use the error handler if needed, and we go to our first line, which says load the Hidden linetype.
If the linetype is already loaded, VB will raise an error code, specifially code " -2145386405" which is what we want to trap on.
 So,
Code: [Select]
Public Sub LLINE()
On Error GoTo ErrorHandler
ThisDrawing.Linetypes.Load "HIDDEN", "J:\TEP SUPPORT\ACAD.LIN"
ThisDrawing.Linetypes.Load "DASHED", "J:\TEP SUPPORT\ACAD.LIN"
Exit Sub

ErrorHandler:
Select Case Err
Case -2145386405:
Err.Clear
Resume Next

Case Else:
Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext

End Select
End Sub

So if Err = -2145386405, Clear the Err and then resume the program with the next line.
Knowing that the error was caused by the linetype already being loaded, we can trap that and move on without the user seeing
an error message.

Was everybody able to generate an error message before?  Was the number the same?  It should have been, because that is the number for duplicate linetypes
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)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
New Project Step 1 Linetypes
« Reply #38 on: July 12, 2005, 12:09:59 PM »
Quote
Was everybody able to generate an error message before? Was the number the same?

Yes to both.

On the code you posted. I still get the error dialog when I run the program. Or are we supposed to.
TheSwamp.org  (serving the CAD community since 2003)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #39 on: July 12, 2005, 12:12:27 PM »
no, your not supposed to, what code did you type in?  the -2145386405 number was the one we were searching for.  Can you post your code?
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)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
New Project Step 1 Linetypes
« Reply #40 on: July 12, 2005, 12:22:11 PM »
I used your code two posts up.

In the dialog I get
Quote
run-time error '-2145386405 (8020005b)':
duplicate record name
TheSwamp.org  (serving the CAD community since 2003)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #41 on: July 12, 2005, 12:44:15 PM »
I could have typoed as well  hold on
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)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #42 on: July 12, 2005, 12:47:34 PM »
in the IDE, go to Tools->Options, General Tab, Error Trapping,  Are you set on Break on all errors?  Set to Break on UnHandled Errors
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)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
New Project Step 1 Linetypes
« Reply #43 on: July 12, 2005, 12:59:22 PM »
Quote from: CmdrDuh
in the IDE, go to Tools->Options, General Tab, Error Trapping,  Are you set on Break on all errors?  Set to Break on UnHandled Errors

That worked. :oops:
TheSwamp.org  (serving the CAD community since 2003)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4073
New Project Step 1 Linetypes
« Reply #44 on: July 12, 2005, 01:00:19 PM »
Dont feel bad.  That one had me stumped for days when I got started
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)