Changes does't get saved...

Changes does't get saved...

Anonymous
Not applicable
688 Views
1 Reply
Message 1 of 2

Changes does't get saved...

Anonymous
Not applicable

Hi, I'm running a LISP that changes color of all objects in the dwg to ByLayer.

 

Problem is that when I do this on an Xref that contains another Xref inside the changes for the "inner" xref doesnt get saved after re-opening.

only the primary Xref (the top one). My VISRETAIN var is set to 1

 

Can you please help me figure that out?

 

(defun c:fixcolor ( / obj vlobj mainBlock childEnt vlobj)
;; Unlock all layers
(vlax-for lay (vla-get-Layers
(vla-get-Activedocument (vlax-get-acad-object))
)
(if (= :vlax-true
(vla-get-lock lay)
)
(progn
(vla-put-lock lay :vlax-false)
(setq lay_lst (cons lay lay_lst))
)
)
)
  ;Start with regular entities
  (setq obj (entnext))
  (while obj
    (setq vlobj (vlax-ename->vla-object obj))
    (vla-put-color vlobj 256)
    (setq obj (entnext obj))
    )
  ;Process entities within blocks
  (setq mainBlock (tblnext "block" t))
  (while mainBlock
    (setq childEnt (cdr (assoc -2 mainBlock)))
    (while childEnt
      (setq vlobj (vlax-ename->vla-object childEnt))
      (vla-put-color vlobj 256)
      (setq childEnt (entnext childEnt))
      );end while
    (setq mainBlock (tblnext "block"))
    )
  (command ".regen")
  (princ)  
  )
0 Likes
689 Views
1 Reply
Reply (1)
Message 2 of 2

Moshe-A
Mentor
Mentor

tom hi,

 

well there are 2 way (as far as i know) to do this:

 

1) base on setbylayer command

    you can write a script file to open each xref on it's own session including the host file

 

2)  use the following function to open each xref and get a pointer to the document

     than scan the database (totaly with activex) do your set bylayer and then save it  using (vla-save dbx) + (vla-close dbx)

     than reload all xrefs

 

(defun doc_open_dbx (dwgFile / dwgpath)
 (setq dbx (vlax-create-object (strcat "ObjectDBX.AxDbDocument." (substr (getvar 'acadver) 1 2))))
 (if (setq dwgpath (findfile dwgFile))
  (progn
   (vla-open dbx dwgpath)
   dbx
  )
  (progn
   (vlax-release-object dbx)
   nil
  )
 )
)

i my self never done this so you will have to explore it .

 

 

 

cheers

moshe

0 Likes