update layer color in documents collection
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
update layer color in documents collection
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
LUCAS
Guest





Posted: Fri Apr 08, 2005 7:29 am    Post subject: Re: update layer color in documents collection Reply with quote

;;By LUCAS
;;change the "CTAB"
;;but not for odbx
(defun C:TEST (/ DOCUMENTS CLRNUM LAYERS NAME)
(setq DOCUMENTS (vla-get-documents (vlax-get-acad-object)))
(initget 7)
(setq CLRNUM (getint "\nEnter layer zero color number: "))
(vlax-for X DOCUMENTS
(setq LAYERS (vla-get-layers X))
(vlax-put (vla-item LAYERS "0") 'COLOR CLRNUM)
(if (= (setq NAME (vla-getvariable X "ctab")) "Model")
(progn
(vla-setvariable X "ctab" NAME)
(vla-setvariable X "ctab" "Model")
)
(progn
(vla-setvariable X "ctab" "Model")
(vla-setvariable X "ctab" NAME)
)
)
)
)


--

http://www.mjtd.com/bbs/



"Joe Burke" <joburke@hawaii.rr.com> 在郵件 news:42551697$1_2@newsprd01 中撰
寫...
Quote:
James,

Oh, that thread... another flying saucer. :-)

Joe

vla-Update:

Here's the context:
http://discussion.autodesk.com/thread.jspa?messageID=4226890

In that particular case, it seemed to help the problem but in the end
didn't
entirely resolve it.

Color:

When I get into 2k6 I'll let you know, if someone else doesn't first.

James



Back to top
LUCAS
Guest





Posted: Fri Apr 08, 2005 8:02 am    Post subject: Re: update layer color in documents collection Reply with quote

;;RENEW
(defun C:TEST (/ DOCUMENTS CLRNUM LAYERS NAME)
(setq DOCUMENTS (vla-get-documents (vlax-get-acad-object)))
(initget 7)
(setq CLRNUM (getint "\nEnter layer zero color number: "))
(vlax-for X DOCUMENTS
(setq LAYERS (vla-get-layers X))
(vlax-put (vla-item LAYERS "0") 'COLOR CLRNUM)
(if
(= (strcase
(vlax-variant-value (setq NAME (vla-getvariable X "ctab")))
)
"MODEL"
)
(progn
(vla-setvariable
X
"ctab"
(vla-get-name (vla-item (vla-get-layouts X) 1))
)
(vla-setvariable X "ctab" "MODEL")
)
(progn
(vla-setvariable X "ctab" "MODEL")
(vla-setvariable X "ctab" NAME)
)
)
(vla-regen X acallviewports)
)
)


"LUCAS" <lai_wan_lung@pchome.com.tw> 在郵件 news:4255fb10$1_1@newsprd01 中撰
寫...
Quote:
;;By LUCAS
;;change the "CTAB"
;;but not for odbx
(defun C:TEST (/ DOCUMENTS CLRNUM LAYERS NAME)
(setq DOCUMENTS (vla-get-documents (vlax-get-acad-object)))
(initget 7)
(setq CLRNUM (getint "\nEnter layer zero color number: "))
(vlax-for X DOCUMENTS
(setq LAYERS (vla-get-layers X))
(vlax-put (vla-item LAYERS "0") 'COLOR CLRNUM)
(if (= (setq NAME (vla-getvariable X "ctab")) "Model")
(progn
(vla-setvariable X "ctab" NAME)
(vla-setvariable X "ctab" "Model")
)
(progn
(vla-setvariable X "ctab" "Model")
(vla-setvariable X "ctab" NAME)
)
)
)
)


--

http://www.mjtd.com/bbs/



"Joe Burke" <joburke@hawaii.rr.com> 在郵件 news:42551697$1_2@newsprd01 中

寫...
James,

Oh, that thread... another flying saucer. :-)

Joe

vla-Update:

Here's the context:
http://discussion.autodesk.com/thread.jspa?messageID=4226890

In that particular case, it seemed to help the problem but in the end
didn't
entirely resolve it.

Color:

When I get into 2k6 I'll let you know, if someone else doesn't first.

James



Back to top
Luis Esquivel
Guest





Posted: Fri Apr 08, 2005 8:34 am    Post subject: Re: update layer color in documents collection Reply with quote

Muy bien Lucas,

Here is another form, using one reactor and the vl-propagate function.

Code:

(defun C:TEST  (/ DOCUMENTS CLRNUM LAYERS NAME)
  (setq DOCUMENTS (vla-get-documents (vlax-get-acad-object)))
  (initget 7)
  (setq CLRNUM (getint "\nEnter layer zero color number: "))
  (vlax-for X  DOCUMENTS
    (setq LAYERS (vla-get-layers X))
    (vlax-put (vla-item LAYERS "0") 'COLOR CLRNUM)
;;;    (if   (= (setq NAME (vla-getvariable X "ctab")) "Model")
;;;      (progn
;;;   (vla-setvariable X "ctab" NAME)
;;;   (vla-setvariable X "ctab" "Model")
;;;   )
;;;      (progn
;;;   (vla-setvariable X "ctab" "Model")
;;;   (vla-setvariable X "ctab" NAME)
;;;   )
;;;      )
    )

  (vl-propagate 'CLRNUM)

  )

;; also place the update and the reactor calls in the acad.mnl

(defun update  (reactor params / layers dwg layer)

  (setq   layer
    (vla-item (setq layers   (vla-get-layers
              (setq   dwg (vla-get-activedocument
                     (vlax-get-acad-object)))))
         "0"))

  (vlax-put layer 'color CLRNUM)

;;;;;;;;;  (vla-regen dwg acAllViewports)

  )

(if (not reactor)
  (setq   reactor
    (vlr-docmanager-reactor
      nil
      '((:vlr-documentBecameCurrent . update)))))




Also, notice if you change on the command line the variable CLRNUM and then (vl-propagate 'CLRNUM)

Now go from one drawing to another.... is the color for the layer changing?

LE

Back to top
Joe Burke
Guest





Posted: Fri Apr 08, 2005 7:40 pm    Post subject: Re: update layer color in documents collection Reply with quote

Lucas,

I tested both versions you posted. Neither one solves the problem on my machine
running 2004. I still have to use the layer dropdown menu, or invoke Layer Manager,
for the color of layer zero to change as it should in open documents other than the
active document.

I appreciate the effort.

Thanks
Joe Burke
Back to top
Luis Esquivel
Guest





Posted: Fri Apr 08, 2005 8:04 pm    Post subject: Re: update layer color in documents collection Reply with quote

Hi Joe,

I'm testing the following under AutoCAD 2004, and appears to work.... please give it a try...

Code:

(defun C:TEST  (/ DOCUMENTS CLRNUM LAYERS NAME)
  (setq DOCUMENTS (vla-get-documents (vlax-get-acad-object)))
  (initget 7)
  (setq CLRNUM (getint "\nEnter layer zero color number: "))
  (vlax-for X  DOCUMENTS
    (setq LAYERS (vla-get-layers X))
    (vlax-put (vla-item LAYERS "0") 'COLOR CLRNUM))
  (if CLRNUM
    (vl-propagate 'CLRNUM)))

;; this function must be also loaded from the acad.mnl
(defun update  (reactor params / layers dwg layer acado)
  (setq   layer
    (vla-item (setq layers   (vla-get-layers
              (setq   dwg (vla-get-activedocument
                     (setq acado (vlax-get-acad-object))))))
         "0"))
  (if CLRNUM
    (vlax-put layer 'color CLRNUM)))

;; this function must be also loaded from the acad.mnl
(if (not reactor)
  (setq   reactor
    (vlr-docmanager-reactor
      nil
      '((:vlr-documentBecameCurrent . update)))))

(princ)
Back to top
Joe Burke
Guest





Posted: Fri Apr 08, 2005 9:24 pm    Post subject: Re: update layer color in documents collection Reply with quote

Luis,

Yes, that works. :-)

Though I must confess I don't understand how, since I know nothing about reactors.
More to learn...

Thanks. Your advice is welcome as usual.

Joe

Quote:
Hi Joe,

I'm testing the following under AutoCAD 2004, and appears to work.... please give
it a try...

Code:

(defun C:TEST  (/ DOCUMENTS CLRNUM LAYERS NAME)
(setq DOCUMENTS (vla-get-documents (vlax-get-acad-object)))
(initget 7)
(setq CLRNUM (getint "\nEnter layer zero color number: "))
(vlax-for X  DOCUMENTS
(setq LAYERS (vla-get-layers X))
(vlax-put (vla-item LAYERS "0") 'COLOR CLRNUM))
(if CLRNUM
(vl-propagate 'CLRNUM)))

;; this function must be also loaded from the acad.mnl
(defun update  (reactor params / layers dwg layer acado)
(setq layer
(vla-item (setq layers (vla-get-layers
(setq dwg (vla-get-activedocument
(setq acado (vlax-get-acad-object))))))
"0"))
(if CLRNUM
(vlax-put layer 'color CLRNUM)))

;; this function must be also loaded from the acad.mnl
(if (not reactor)
(setq reactor
(vlr-docmanager-reactor
nil
'((:vlr-documentBecameCurrent . update)))))

(princ)
Back to top
Luis Esquivel
Guest





Posted: Fri Apr 08, 2005 9:36 pm    Post subject: Re: update layer color in documents collection Reply with quote

That's good...



Take care Joe!


LE.
Back to top
Luis Esquivel
Guest





Posted: Fri Apr 08, 2005 10:03 pm    Post subject: Re: update layer color in documents collection Reply with quote

I mean.... is good that works

And why works... is that I found that the only way to update the layer was to have it at the time of making current the document.

LE.
Back to top
Tony Tanzillo
Guest





Posted: Fri Apr 08, 2005 10:30 pm    Post subject: Re: update layer color in documents collection Reply with quote

We can't say that 'that works', because what
You're doing is trying to modify something in a
document that's not active.

What luis is doing, is waiting until the document
becomes active to do the same thing.

What you may not realize is that luis' reactor is
not executing the update code until you switch
to the document.

The whole thing seems a little silly, since this
creates more problems than it solves.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Joe Burke" <joburke@hawaii.rr.com> wrote in message news:4256be6a$1_3@newsprd01...
Quote:
Luis,

Yes, that works. :-)

Though I must confess I don't understand how, since I know nothing about reactors. More to learn...

Thanks. Your advice is welcome as usual.

Joe

Hi Joe,

I'm testing the following under AutoCAD 2004, and appears to work.... please give it a try...

Code:

(defun C:TEST  (/ DOCUMENTS CLRNUM LAYERS NAME)
(setq DOCUMENTS (vla-get-documents (vlax-get-acad-object)))
(initget 7)
(setq CLRNUM (getint "\nEnter layer zero color number: "))
(vlax-for X  DOCUMENTS
(setq LAYERS (vla-get-layers X))
(vlax-put (vla-item LAYERS "0") 'COLOR CLRNUM))
(if CLRNUM
(vl-propagate 'CLRNUM)))

;; this function must be also loaded from the acad.mnl
(defun update  (reactor params / layers dwg layer acado)
(setq layer
(vla-item (setq layers (vla-get-layers
(setq dwg (vla-get-activedocument
(setq acado (vlax-get-acad-object))))))
"0"))
(if CLRNUM
(vlax-put layer 'color CLRNUM)))

;; this function must be also loaded from the acad.mnl
(if (not reactor)
(setq reactor
(vlr-docmanager-reactor
nil
'((:vlr-documentBecameCurrent . update)))))

(princ)


Back to top
Luis Esquivel
Guest





Posted: Fri Apr 08, 2005 10:37 pm    Post subject: Re: update layer color in documents collection Reply with quote

Yes

As always Tony is right.

Tony, can you elaborate more on the problems, you mention, please.


LE.
Back to top
Tony Tanzillo
Guest





Posted: Fri Apr 08, 2005 11:09 pm    Post subject: Re: update layer color in documents collection Reply with quote

Luis - Please try to stop thinking about solutions
to problems, only in terms of 'reactors'.

You are trying to solve every problem with reactors,
and in some cases, your proposed solutions are very
shortsighted, because you overlook the problems
that your reactor-based solutions also create.

You can't solve one problem by creating another
problem.

You update the layers in every document, every
single time the user activates it. Do I really need
to explain what's wrong with that?


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Luis Esquivel" <nospam@address.withheld> wrote in message
news:32686536.1112985455055.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
Yes

As always Tony is right.

Tony, can you elaborate more on the problems, you mention, please.


LE.
Back to top
Luis Esquivel
Guest





Posted: Fri Apr 08, 2005 11:26 pm    Post subject: Re: update layer color in documents collection Reply with quote

I see your point Tony and thank you, I understand.

I won't proposed anymore solution with reactors for cases like or better I won't talk to much about them over here.

I only want it to find out a way to at least have the color for the layer updated.... just that.

Tony I am not a professional programmer, I know that.

Now, I would like to learn from you, would like to have me as an intern?... I even would work for free, and I'm serious.

Best regards,
Luis.
Back to top
Tony Tanzillo
Guest





Posted: Fri Apr 08, 2005 11:30 pm    Post subject: Re: update layer color in documents collection Reply with quote

Luis - I never said you were claiming to be a professional
programmer, just that you were going 'overboard' with the
reactor-based programming.

Reactors have their place, but there are times when they
create more problems than they solve. The key is to try
to learn more about AutoCAD's internal bahavior, so you
can foresee when reactors are not the right solution.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Luis Esquivel" <nospam@address.withheld> wrote in message
news:17894357.1112988442433.JavaMail.jive@jiveforum2.autodesk.com...
Quote:
I see your point Tony and thank you, I understand.

I won't proposed anymore solution with reactors for cases like or better I won't talk to much about them over here.

I only want it to find out a way to at least have the color for the layer updated.... just that.

Tony I am not a professional programmer, I know that.

Now, I would like to learn from you, would like to have me as an intern?... I even would work for free, and I'm
serious.

Best regards,
Luis.
Back to top
Luis Esquivel
Guest





Posted: Fri Apr 08, 2005 11:52 pm    Post subject: Re: update layer color in documents collection Reply with quote

Thank you.

Just to comment, lately I am more focus in other type of exercises code solutions, as my latest post about gpoly, that you maybe saw it....

And how you would solve something like the OP is looking, or this type of solution does not worth to even spent on them?

And I see you ignored my last part of my previous post... :-(


LE
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB