VB.NET + GetEntity

Discussion in 'AutoCAD' started by Elscimar, Oct 21, 2004.

  1. Elscimar

    Elscimar Guest

    Hi. I'm trying to grab a dimension via GetEntity so I can pull some info off of it, for use in my program. Here's the code:

    Dim p As Object
    Dim olddim As Autodesk.AutoCAD.Interop.Common.AcadDimension
    Try
    Dim utils As AcadUtility = CType(CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, AcadApplication).ActiveDocument.Utility, AcadUtility)
    utils.GetEntity(olddim, p, "Pick the Dimension")
    Catch
    End Try

    It just doesn't seem to be able to catch errors that occur when you click somewhere and don't select an object. Any ideas?
     
    Elscimar, Oct 21, 2004
    #1
  2. Elscimar

    Mikko Guest

    Here is what I use to select a Detail Balloon.

    Dim ReturnBall As Object
    Dim BasePt(2) As Double

    Retry:
    acadUtl.GetEntity(ReturnBall, BasePt, "Select a Balloon")
    If ReturnBall.EntityName <> "AcDbCircle" Then
    AppActivate("Ball-n-Stock")
    MessageBox.Show("You must select a Balloon", "Ball-n-Stock", MessageBoxButtons.OK, MessageBoxIcon.Information)
    AppActivate(ACADApp.Caption)
    GoTo Retry
     
    Mikko, Oct 21, 2004
    #2
  3. On Wed, 20 Oct 2004 23:51:50 GMT, Elscimar wrote:
    If you code is exactly as you have it here, it doesn't do anything because
    you haven't told it what to do. Read up on the Try..Catch loop it should
    look like this:

    Try
    utils.GetEntity(olddim, p, "Pick the Dimension")
    Catch
    Messagebox.ShowDialog("Didn't pick anything")
    End Try

    You can also catch specific errors by having mulitple catches

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 21, 2004
    #3
  4. Elscimar

    Elscimar Guest

    D'oh. I was under the (obviously mistaken) impression that just having the Catch there would cause it to supress the popup.
     
    Elscimar, Oct 21, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.