Author Topic: "Error: vla-object Object open for read"?  (Read 5299 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
"Error: vla-object Object open for read"?
« on: April 27, 2004, 04:39:42 PM »
Could someone help with a small problem? This is still in "theory mode" so pardon the crudness.

Pseudo Code:
Code: [Select]
Objective: Offset to a specific layer
         - Must act like offset command.

Start offset command
Loop -->
- Promt the user for an object.
  ~ Use in the Offset command
- Prompt the user for a point.
  ~ Use in the offst command
- Store each object made in a list
<-- End Loop
Change the list of objects layer to a known layer.
end.


That is basicly what i wanted to accomplish (well that is my Pseudo Code so its alot like my existing code.)

My origional idea was to make a quick and dirty tool for offseting to a specific layer.

Heres my problem. When you offset a line like this: (I call it making a ladder)
-------------- <- etc., ect.
-------------- <- 2nd offset
-------------- <- 1st offset
-------------- <- Origional line

Not all the objects are changing layers. i believe the problem is because of the "entlast" function but i can think of another method off the top of my head. Can you?

Heres the code:
Code: [Select]
(defun c:offset2layer (/ ent pnt)
  (setq templst nil)
  (command "_.Offset" PAUSE)
  (while (setq ent (entsel))
     (setvar "cmdecho" 0)
     (command ent)
     (setq pnt (getpoint "\nPick a point you dummy: "))
     (command pnt)
;     (redraw (entlast) 3) ; <- Uncoment this line for and witness my confusion
     (setq templst (cons (entlast) templst))
    );_ end while
  (setvar "cmdecho" 1)
  (mapcar
    '(lambda (x)
       (setq x (vlax-ename->vla-object x))
       (vlax-put-property x 'LAYER "MD-OUTLINE")
       (vlax-release-object x))
    templst);_ end mapcar
  (command)
  );_ end defun
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
"Error: vla-object Object open for read"?
« Reply #1 on: April 27, 2004, 07:11:17 PM »
Hmmmm .... I have absolutely no problem with the above code in 2004....however after perusing it a bit, might I make a suggestion....of course I might... otherwise you would not have posted the dang thing....

There are some automation protocols in 2000 and 2002 that create problems in lisp, vba and VLisp that you should be aware of...

Any time you issue a command or a command is in progress and you try to manipulate an object modified or created by that command in progress you will have this error, many times it is a fatal error and AutoCAD will crash or lock up....

The problem is perhaps related to the way ActiveX handles objects and the way a command handles objects...

Any command i.e. (command "blah blah blah" ...) that creates, edits, or otherwise changes an object does not commit the changes to the drawing database until the command is ended...the result is that the object was opened for read, not write. You might try adding a closing command call right after the while loop thereby assuring that the offset command is indeed finished and the objects are no longer under the control of the command interface.

Incedently this same thing happens if you try to modify an object through VLisp immediately after it was modified by VBA using an "End_Command" reactor.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
"Error: vla-object Object open for read"?
« Reply #2 on: April 27, 2004, 10:15:32 PM »
Your a genius!! ..."Move the comand" How simple was that?!?!? Oh, that was awesome!

Thanx!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
"Error: vla-object Object open for read"?
« Reply #3 on: April 27, 2004, 10:23:34 PM »
Quote from: Se7en
Your a genius!! ..."Move the comand" How simple was that?!?!? Oh, that was awesome!

Thanx!


Nah.... I just had that problem before and finally figured it out when I was able to duplicate the error and fix it..... You would think that Autodesk would have something written about this, but they don't. The only reason I know about the commands commiting objects to the database is because I read it in the ARX documentation where it said that the program must commit all objects to the drawing BEFORE another command is called. It didn't explain why, just that you needed to do it...

I take it that it works properly now?

Oh... and I have only seen this behavior in VLisp and VBA not when using lisp straight up.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
"Error: vla-object Object open for read"?
« Reply #4 on: April 27, 2004, 10:31:26 PM »
Sure is.

You know, now  that i think about it more i think i remeber reading something along those lines somewhere or another.

Yeah they suck at telling you what dosent work dont they?! its all "this works and ...this is great" but not alot of "watch out for this... and this just flat out sucks in this version."

damn Acad
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
"Error: vla-object Object open for read"?
« Reply #5 on: April 27, 2004, 11:52:57 PM »
Guess you could stick a wait in there?

Code: [Select]
 (while (>(getvar "CMDACTIVE")0) () )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
"Error: vla-object Object open for read"?
« Reply #6 on: April 28, 2004, 08:52:20 AM »
No sir. Dont want that.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
"Error: vla-object Object open for read"?
« Reply #7 on: April 28, 2004, 12:47:13 PM »
Quote from: CAB
Guess you could stick a wait in there?

Code: [Select]
 (while (>(getvar "CMDACTIVE")0) () )


I thought about that ... but I figured that simply closing the command should suffice...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
"Error: vla-object Object open for read"?
« Reply #8 on: April 28, 2004, 03:10:51 PM »
I know this is not the way you would do it but,


Code: [Select]
(defun c:offset2layer (/ ent dist prvdist pt loop)
  (setvar "cmdecho" 1)
  (setq loop t)
  (while loop
    (setq prvdist (getvar "offsetdist"))
    (if
      (and
        (if (setq dist (getdist
                         (strcat "\nSpecify offset distance or [Through] <"
                                 (rtos prvdist 4)
                                 ">:"
                         )
                       )
            )
          dist
          (setq dist prvdist)
        )
        (setq ent (entsel "\nSelect object to offset or <exit>:"))
        (not
          (while
            (not (setq pt (getpoint "\nSpecify point on side to offset:")))
             (princ "\nPlease try again...")
          )
        )
      )
       (progn
         (command "_.Offset" dist ent pt "")
         (command "_.chprop" (entlast) "" "LA" "MD-OUTLINE" "")
       )
       (setq loop nil) ; done
    )
  ) ;_ end while
  (setvar "cmdecho" 0)
  (princ)
) ;_ end defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
"Error: vla-object Object open for read"?
« Reply #9 on: April 28, 2004, 03:35:34 PM »
Which proves there is more than one way to skin a cat...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
"Error: vla-object Object open for read"?
« Reply #10 on: April 28, 2004, 03:36:09 PM »
I like this one a little better, only ask once for the distance.

Code: [Select]
(defun c:offset2layer (/ ent dist prvdist pt loop)
  (setvar "cmdecho" 1)
  (setq prvdist (getvar "offsetdist"))
  (if (setq dist (getdist
                   (strcat "\nSpecify offset distance or [Through] <"
                           (rtos prvdist 4)
                           ">:"
                   )
                 )
      )
    dist
    (setq dist prvdist)
  )

  (setq loop t)
  (while loop
    (if
      (and
        (setq ent (entsel "\nSelect object to offset or <exit>:"))
        (setq pt (getpoint "\nSpecify point on side to offset:"))
      )
       (progn
         (command "_.Offset" dist ent pt "")
         (command "_.chprop" (entlast) "" "LA" "MD-OUTLINE" "")
       )
       (setq loop nil) ; done
    )
  ) ;_ end while
  (setvar "cmdecho" 0)
  (princ)
) ;_ end defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.