Jump to content

Object is not write enabled


cletero

Recommended Posts

Hi,

 

My question is, what makes an object "not write enabled" and how can I change it?

 

I'm having trouble with a lisp that uses entmod to modify a polyline, however it fails the second time around and using this line:

(setq test_3 (vlax-write-enabled-p obj))

I can tell the polyline being modified is NOT write enabled, so the entmod line fails.

 

Using vla-update seemed to work in other part of the program (which I had posted in a different thread), but it doesn't in this particular case.

 

Any ideas?

Link to comment
Share on other sites

An Object that is already opened for modify cannot be written to (until the Close() Method is called for same).

 

Just as a quick observation, you're ENTMODing an entity that you've already accessed via VLA-OBJECT; just modify the VL Properties, no? Perhaps if you'd post your code there'd be a more obvious suggestion.

 

Cheers

Link to comment
Share on other sites

My question is, what makes an object "not write enabled"

 

Includes any or all of the following:

 

  • Object is erased.

 

  • Object is on a locked layer.

 

  • Object is being modified from within a reactor callback function when the active command is already modifying the object.

Link to comment
Share on other sites

Thank you all guys! I'd like to put my code here but it's like a zillion lines long... basically, the lines which may be of importance are these:

 

A polyline which goes thru a check to get if its running cw or counter cw:

(plinedir pln) ;This checks polylines direction
;if it's going the wrong way when compared with "cutdirection" it will be reversed:
(cond 
           ((and (= cutdirection "climb") (= pl_direction "ccw"))
                 (setq pl_direction "cw")
                 ([b][color=red]reverse_pline[/color][/b] pln)
            )
            ((and (= cutdirection "conv") (= pl_direction "cw"))
                  (setq pl_direction "ccw")
                  ([b][color=red]reverse_pline[/color][/b] pln)(plinedir pln)
            )
 )

If necesary, it's direction will be reversed with this:

 

(defun [b][color=red]reverse_pline[/color][/b] (mypoly / e_lst p_lst v_lst l_vtx x)
   ;(setq test_1 (vlax-object-released-p obj)) (setq test_2 (vlax-read-enabled-p obj))
   ;(setq test_3 (vlax-write-enabled-p obj)) ;Un-comment this lines to test object status
   (vla-update mypoly)    ;Use this line to make mypoly write enabled when shademode is not 2d wireframe or other issues
   ;(setq test_1 (vlax-object-released-p obj)) (setq test_2 (vlax-read-enabled-p obj))
   ;(setq test_3 (vlax-write-enabled-p obj))
   (setq e_lst (entget (vlax-vla-object->ename mypoly)))
   (setq
       p_lst (vl-remove-if-not '(lambda (x) (member (car x) '(10 40 41 42))) e_lst)
       e_lst (vl-remove-if '(lambda (x) (member x p_lst)) e_lst)
   )
   (while p_lst
       (setq
           v_lst (cons (list (car p_lst) (cadr p_lst) (caddr p_lst) (cadddr p_lst)) v_lst)
           p_lst (member (assoc 10 (cdr p_lst)) (cdr p_lst))
       )
   )
   (setq
       l_vtx (last v_lst)
       l_vtx (subst (cons 40 (cdr (assoc 41 (car v_lst)))) (assoc 40 l_vtx) l_vtx)
       l_vtx (subst (cons 41 (cdr (assoc 40 (car v_lst)))) (assoc 41 l_vtx) l_vtx)
       l_vtx (subst (cons 42 (- (cdr (assoc 42 (car v_lst))))) (assoc 42 l_vtx) l_vtx)
   )
   (setq
       v_lst (mapcar '(lambda (x y)
           (setq x (subst (cons 40 (cdr (assoc 41 y))) (assoc 40 x) x)
               x (subst (cons 41 (cdr (assoc 40 y))) (assoc 41 x) x)
               x (subst (cons 42 (- (cdr (assoc 42 y)))) (assoc 42 x) x)
           )) v_lst (cdr v_lst))
   )
   (if (= (logand 1 (cdr (assoc 70 e_lst))) 1)
       (setq v_lst (append (list l_vtx) v_lst))
       (setq v_lst (append v_lst (list l_vtx)))
   )
   (setq e_lst (append e_lst (apply 'append v_lst)))
   [color=red](entupd (cdr (assoc -1 ([b]entmod[/b] e_lst))))  [/color]
   (command "_.regen")
   (princ)
)

That's when entmod fails, but only the second time I run the code (ex: I run it on object1, goes fine, it ends and call it again, entmod line fails.

 

I have the exact same procedure in another part of my routine and it worls perfectly, so I'm not sure what's happenning. The only difference, in fact, was that some layers where frozen on the routine that fails, so i changed that but didn't help.

 

Thanks for any help.

Edited by cletero
Link to comment
Share on other sites

Your reverse_pline defun works fine, it reverses the clockwise to counter-Clockwise and vice versa. But I do it with a new drawing,

Maybe you post your file which the defun fails to work.

Link to comment
Share on other sites

I have been trying to post an answer for a few days but for some reason it gets rejected... anyway... I got to try my program in a machine with AutoCAD 2014 and it works perfectly, so I wonder if there's a setting or variable on my machine (AutoCAD 2000) that may be causing the problem?

 

I was able to work around the problem by using an vla-update IF the object is NOT write enabled. Curiously, if the object IS write enabled and I use the vla-update then it goes into NOT write enabled. Is this normal?

 

Any thoughts?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...