Object Variable or With Block variable not set

Discussion in 'AutoCAD' started by vencad, Jul 15, 2004.

  1. vencad

    vencad Guest

    Hi
    I am trying to create a VB program which will get the value of setvar TDindwg when ever a file open event occurs. Everything works fine but when ever it reaches this point
    Dim mytime1
    mytime1 = ThisDrawing.GetVariable("TDINDWG")
    The program terminates with the above error message given in the topic tile.
    Can any one help me.
     
    vencad, Jul 15, 2004
    #1
  2. I added those 2 lines to a new procedure and it works fine. I think your problem may lie elsewhere.
    Regards - Nathan
     
    Nathan Taylor, Jul 16, 2004
    #2
  3. vencad

    MP Guest

    if it's a vb - not a vba - program, ThisDrawing may not be initialized.
    if you're in autocad vba it has a meaning, otherwise it's just another
    variable name.
    how are you connecting to autocad and it's events?

    have you Set ThisDrawing = something????


    TDindwg when ever a file open event occurs. Everything works fine but when
    ever it reaches this point
     
    MP, Jul 16, 2004
    #3
  4. vencad

    Norman Yuan Guest

    When you say "everything is works fine but...", what kind of code is there
    that works? If you could provide more info...

    Just my guess here, since you stated "a file open event"
    Since only AcadApplication object has BeginOpen and EndOpen event, so, do
    you run this code in either BeginOpen or EndOpen event handler? If your code
    is in BeginOpen, then of course, the object "ThisDrawing" is not there yet,
    so the error.

    TDindwg when ever a file open event occurs. Everything works fine but when
    ever it reaches this point
     
    Norman Yuan, Jul 16, 2004
    #4
  5. vencad

    vencad Guest

    I am connecting to AutoCAD like this.

    Public WithEvents AcadApp As AcadApplication
    Public WithEvents ThisDrawing As AcadDocument
     
    vencad, Jul 16, 2004
    #5
  6. vencad

    Tim Arheit Guest

    That doesn't really connect to autocad. It simply declares the
    variables. You still need to do:

    Set AcadApp = something
    Set ThisDrawing = something

    -Tim
     
    Tim Arheit, Jul 16, 2004
    #6
  7. vencad

    Gworge Cox Guest

    In the following code you have to select the polyline which works fine
    Is there a method of modifing the code to run if the polyline is ALREADY
    selected if not select polyline

    thank you

    (defun VL-POLY () ;get the entity and entity name
    (setq THEPL (car (entsel "\nSelect a Walk Polyline: "))
    ;convert to vl object
    THEOBJ (vlax-ename->vla-object THEPL))
    ;check if it's a polyline
    (terpri)
    (if (= (vlax-get-property THEOBJ 'OBJECTNAME) "AcDb3dPolyline")
    (progn
    (setq WALKNO (substr (vla-get-layer THEOBJ) 1 5) ; layer name
    C_TIME (menucmd
    "M=$(edtime,$(getvar,date), DD-MO-YY HH:MM:SS)")
    WALT " " ; 6 dummy spaces for altitude
    IDENT "AA"
    WALKLT (getstring "n\Enter T=Altitude Z=Zero altitude ")
     
    Gworge Cox, Jul 18, 2004
    #7
  8. vencad

    MP Guest

    so you are using vb right?not vba

    where is the code?
    Set ThisDrawing = ...
     
    MP, Jul 19, 2004
    #8
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.