Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PLOT reactor works fine but what about PUBLISH?

12 REPLIES 12
Reply
Message 1 of 13
fk
Advocate
1511 Views, 12 Replies

PLOT reactor works fine but what about PUBLISH?

Hi.

Finely I got my PLOT reactor to work. It writes a string to an attribute before PLOT is executed and check afterword if the user has cancelled the PLOT. If so, it restores the old value in the attribute.

 

So, with the PLOT reactor up and running I thought that PUBLISH would be a piece of cake, but sadly not. In my simple mind, I thought that PUBLISH triggered the PLOT command. But nothing happens with my attribute when I PUBLISH. Is there someone that can tell me how to get my work done with every drawing that is plotted by the PUBLISH command.

 

Thanks in advance.

 

\Freddy

12 REPLIES 12
Message 2 of 13
rmiller1973
in reply to: fk

 

;define function reactor for publish command start and end
(vlr-command-reactor 
	nil '((:vlr-commandWillStart . start-cmd)))
(vlr-command-reactor 
	nil '((:vlr-commandEnded . end-cmd)))

;publish command starts - set bulletin board variable to 1
(defun start-cmd (calling-reactor start-cmdInfo / 
		     cmd-start)
(setq cmd-start (nth 0 start-cmdInfo))
(cond
  ((= cmd-start "PUBLISH") (vl-bb-set 'bb-Publish "1"))
);cond
(princ)
);defun

;publish command ends - call fc:cmd-Publish function
(defun end-cmd (calling-reactor end-cmdInfo / 
		   cmd-end)
(setq cmd-end (nth 0 end-cmdInfo))
(cond
  ((= cmd-end "PUBLISH") (fc:cmd-Publish))
);cond
 (princ)
);defun


;evaluate publish reactor on drawing open
;if value not equal to (1) one - load menu routines
;else quick open - none loaded
(if (/= (vl-bb-ref 'bb-Publish) "1")
  (progn
    (load "CFG-runonce.lsp") ;standard environment menu support
  )
  (progn
    (print "Menu: NONE Loaded") ;publish environment quick open
  )
)

;set bulletin board for standard file open
;when publish is called bulletin board is
;updated to run reactor on all files, reset on end
(defun fc:cmd-Publish ( / )
  (vl-bb-set 'bb-Publish "0")
)

 You can try the code above:

 

I have it added to the menu load rountine (MNL) so the reactor is loaded and ready for evaluation in every file. I believe the Publish command is a single event so it requires a method to pass that information to the published set. So that is why the bulletin board is being used to expose that the publish command is active for each drawing in the set.

 

Our environment is extremely customized so our Publish reactor was set to reduce the menu load and custom routines down to a minimum - to mimic opening the default AutoCAD profile. You can remove that aspect out of the reactor but I figured I would explain how it was currently setup.

 

Anyway, a standard open would result in the bulletin board value for the Publish command to be set to "0". If the Publish command is called the bulletin board value is set to "1" and it will remain that way until the command ends. At which time the last section will allow the bulletin board to reset and switch back to a normal load.

 

Reactor might not work correctly with a Publish called from certain elements of the Project Navigator or Sheet Set Manager - if you open the Publish dialog box it should work. I will see if I can isolate how the Project Navigator or Sheet Set Manager is calling the command if you need it.

 

Rob

 

Message 3 of 13
fk
Advocate
in reply to: rmiller1973

Hi.

Thanks for your reply. I'm using the MNL to our startup routines as well. In our MNL file we have defined our startup routines (NO-Start) using the defun-q function. At the end of our MNL file I have this line of code: (setq s::startup (append s::startup NO-start)) in case there is other s::startup somewhere else.

 

In the NO-Start routine I have added your code but when we run the PUBLISH command it looks like it is not triggered at all. I have put in some test code like this:

 

(if (/= (vl-bb-ref 'bb-Publish) "1")
   (princ "\nOK!")  ;standard environment menu support
   (print "\nPublish in progress!")  ;publish environment quick open
)


PUBLISH never prints  "Publish in progress!", it only prints this on the command line:

 

Command: publish
Updating Indexes for block *Model_Space
Done.

\Freddy

 

Message 4 of 13
fk
Advocate
in reply to: fk

Some additional info:

 

I want to use the vlr-layoutswitched reactor:

 

 

(vlr-miscellaneous-reactor nil '((:vlr-layoutswitched . NO_LayoutSwitched)))

 

(defun NO_LayoutSwitched (Reactor LayoutSwitchedInfo)
 (if (/= (vl-bb-ref 'bb-Publish) "1")
    (princ "\nOK!")  ;standard environment menu support
    (print "\nDo my stuff!")  ;publish environment quick open
 )
)

 

In every Layout we have to update an attribute value. This is our plot stamp. If you wonder way we are not useing AutoCAD plot stamp, is the answer that we want to collect xref and image names as well.
 

\Freddy

 

Message 5 of 13
rmiller1973
in reply to: fk

 


@FK wrote:

Some additional info:

 

I want to use the vlr-layoutswitched reactor:

 

 

(vlr-miscellaneous-reactor nil '((:vlr-layoutswitched . NO_LayoutSwitched)))

 

(defun NO_LayoutSwitched (Reactor LayoutSwitchedInfo)
 (if (/= (vl-bb-ref 'bb-Publish) "1")
    (princ "\nOK!")  ;standard environment menu support
    (print "\nDo my stuff!")  ;publish environment quick open
 )
)

 

In every Layout we have to update an attribute value. This is our plot stamp. If you wonder way we are not useing AutoCAD plot stamp, is the answer that we want to collect xref and image names as well.

\Freddy

 


 

Using the layout switch should work out just fine if you have multiple sheet tabs.

 

I was looking over what you said and decided to do a simple test setting up a basic MNL. I defined the information I posted before as a defun-q function called "start_func" where I modified the test to a set of simply alerts - Normal or Publish. This is being called using the function append startup you posted.

 

In our environment I don't normally use startup routines except for background or bulk processing (ie, [acaddoc.lsp] startup -> process file -> save -> index to next file). So the startup would simply call the startup function I created.

 

 

(defun-q start_func ( / )
  ;define function reactor for publish command start and end
(vlr-command-reactor 
	nil '((:vlr-commandWillStart . start-cmd)))
(vlr-command-reactor 
	nil '((:vlr-commandEnded . end-cmd)))

;publish command starts - set bulletin board variable to 1
(defun start-cmd (calling-reactor start-cmdInfo / 
		     cmd-start)
(setq cmd-start (nth 0 start-cmdInfo))
(cond
  ((= cmd-start "PUBLISH") (vl-bb-set 'bb-Publish "1"))
);cond
(princ)
);defun

;publish command ends - call fc:cmd-Publish function
(defun end-cmd (calling-reactor end-cmdInfo / 
		   cmd-end)
(setq cmd-end (nth 0 end-cmdInfo))
(cond
  ((= cmd-end "PUBLISH") (fc:cmd-Publish))
);cond
 (princ)
);defun


;evaluate publish reactor on drawing open
;if value not equal to (1) one - load menu routines
;else quick open - none loaded
(if (/= (vl-bb-ref 'bb-Publish) "1")
  (progn
    (alert "Normal") ;standard environment menu support
  )
  (progn
    (alert "Publish") ;publish environment quick open
  )
)

;set bulletin board for standard file open
;when publish is called bulletin board is
;updated to run reactor on all files, reset on end
(defun fc:cmd-Publish ( / )
  (vl-bb-set 'bb-Publish "0")
)
)

;append startup function with publish command function
(setq s::startup (append s::startup start_func))
(princ)

Once the MNL had been setup and saved I opened a new drawing and I received a "Normal" alert. I then typed in publish and selected a couple of drawing to print to PDF - for each drawing I received a "Publish" alert. I tested this using the file->publish and the "Publish" alert was received again.

 

Are you sure your menu routines are being completely loaded? I ask this because during one of our last upgrades I had to step through all of our lisp routines to verify that each section was being loaded (as well as finding slow down points). You may have noticed in the original post I had a routine called "CFG-runonce.lsp" that was loaded in normal situations. This routine would step through and load all routines that are required for our tools to work correctly (broken down by system reactors and redefined commands, constant functions, drawing configuration, internally created commands, and other commands). At the end of this routine I added in a line to print that the menu has been loaded (print "Menu: Custom for AutoCAD 2010 Loaded").

 

 

I would suggest removing the recently added code and try adding in a similar menu loaded line to your NO-Start function ... it is possible the menu is erroring out and not loading completely. I can't figure out why the Publish command wouldn't work at all unless maybe you might have a reactor that is causing a conflict.

 

See if you can get the reactor to fire on its own (using simplified MNL code above). If it does, verify that your baseline routines are loading completely. If it doesn't try adding in simple alerts inserted incrementally throughout your routines to try to isolate where it might be choking out (stripout and rebuild). If it is loading correctly look at all of the reactors that you migh be using.

 

If you are publishing using Sheet Set Manager or Project Navigator it won't work correctly. They both call the publish command without interacting on a level the reactor can see. VB.Net or VBA might be able to see it?

 

Let me know how it all goes ...

Message 6 of 13
fk
Advocate
in reply to: rmiller1973

Hi.

First of all. I am very grateful that you can bear to spend time on this.

 

This is strange. I replaced all my code in the MNL file with your code. So now the MNL file only contain your code. Started a new drawing and the "Normal" alert appeared. Started the Publish command without any alert. Strange.

 

It is only the MNL file that starts additional code. We have not edited any other files (e.g. acad2011doc.lsp)

We are using AutoCAD 2011.

 

I restarted AutoCAD and added (vl-load-com) to the MNL file. Now I get an alert on PUBLISH too :o) I will look more into this to morrow. Now it is workout. Thanks so much so far.

\Freddy

 

Message 7 of 13
rmiller1973
in reply to: fk

 


@FK wrote:

Hi.

First of all. I am very grateful that you can bear to spend time on this.

 

This is strange. I replaced all my code in the MNL file with your code. So now the MNL file only contain your code. Started a new drawing and the "Normal" alert appeared. Started the Publish command without any alert. Strange.

 

It is only the MNL file that starts additional code. We have not edited any other files (e.g. acad2011doc.lsp)

We are using AutoCAD 2011.

 

I restarted AutoCAD and added (vl-load-com) to the MNL file. Now I get an alert on PUBLISH too :o) I will look more into this to morrow. Now it is workout. Thanks so much so far.

\Freddy

 


 

I forgot about the (vl-load-com) - it seems I must have that line of code in my local cui mnl file.

 

 

(defun-q start_func ( / )
;define function reactor for publish command start and end
(vlr-command-reactor 
	nil '((:vlr-commandWillStart . start-cmd)))
(vlr-command-reactor 
	nil '((:vlr-commandEnded . end-cmd)))

;publish command starts - set bulletin board variable to 1
(defun start-cmd (calling-reactor start-cmdInfo / 
		     cmd-start)
(setq cmd-start (nth 0 start-cmdInfo))
(cond
  ((= cmd-start "PUBLISH") (vl-bb-set 'bb-Publish "1"))
);cond
(princ)
);defun

;publish command ends - call fc:cmd-Publish function
(defun end-cmd (calling-reactor end-cmdInfo / 
		   cmd-end)
(setq cmd-end (nth 0 end-cmdInfo))
(cond
  ((= cmd-end "PUBLISH") (fc:cmd-Publish))
);cond
 (princ)
);defun
	 
;evaluate publish and layour reactor on drawing open
;if equal to (1) one - publish command is active [process]
;layout reactor required for multiple layout publishing
(if (= (vl-bb-ref 'bb-Publish) "1") ;<- switch evaluation to look for publish command
  (progn
    (alert "Publish Reactor") ;publish environment
  )
)

(vlr-miscellaneous-reactor nil '((:vlr-layoutswitched . NO_LayoutSwitched))) ;define layout switch reactor
(defun NO_LayoutSwitched (Reactor LayoutSwitchedInfo) 
  (if (= (vl-bb-ref 'bb-Publish) "1")
    (progn
      (alert "Layout Reactor") ;layout switch - linked to Publish reactor
    )
  )
)

;set bulletin board for standard file open
;when publish is called bulletin board is
;updated to run reactor on all files, reset on end
(defun fc:cmd-Publish ( / )
  (vl-bb-set 'bb-Publish "0")
)
) ;end defun-q start_func

(setq s::startup (append s::startup start_func))
(princ)

 

Here's a sample with the layout reactor included. Keep in mind that you will need the Publish evaluation and the layout reactor - since you are expecting the information to be updated based on the layout switch.

 

Basically, if you leave out the Publish evaluation and the first printed item is the open active tab, there would be no layout reactor call (ie, open on layout1 -> print layout1). Likewise with both loaded, the publish and layout reactor could both be performed on the first tab if there is a switch (ie, open on model -> print layout1) ...this is the preferred method because it guarantees that the evaluation is performed.

 

You might play around to see if you can evaluate for when no layout switch is performed.  think it would become a chicken or the egg type scenario though.

 

Message 8 of 13
hcanas
in reply to: rmiller1973

I know this is a OLD topic, but I was looking for something similar. 

My question for this topic is: can I include a LSP file to be call by the reactor or will not work?

 

I will like to call my LSP file to record the file info that is printed to a text file, mi file name is PLOT_log.lsp, if is posible to call the LSP by name (PLOT_log) where with the Function reactor can I included?

 

Thank you 

 

DC

DC
Message 9 of 13
rmiller1973
in reply to: hcanas

(vl-load-com)

;define function reactor for publish command start and end
(vlr-command-reactor 
	nil '((:vlr-commandWillStart . start-cmd)))
(vlr-command-reactor 
	nil '((:vlr-commandEnded . end-cmd)))

;publish command starts - set bulletin board variable to 1
(defun start-cmd (calling-reactor start-cmdInfo / cmd-start)
(setq cmd-start (nth 0 start-cmdInfo))
(cond
  ((= cmd-start "PUBLISH") (vl-bb-set 'bb-Publish "1"))
);cond end
(princ)
);defun end

;publish command ends - call fc:cmd-Publish function
(defun end-cmd (calling-reactor end-cmdInfo / cmd-end)
(setq cmd-end (nth 0 end-cmdInfo))
(cond
  ((= cmd-end "PUBLISH") (fc:cmd-Publish))
);cond end
 (princ)
);defun end


;evaluate publish reactor on drawing open
;if value not equal to (1) one - load menu routines
;else quick open - none loaded
(if (/= (vl-bb-ref 'bb-Publish) "1")
  (progn
    (print "Standard") ;standard environment, change to princ to suppress "Standard"
  )
  (progn
    (load "PLOT_log.lsp") ;standard environment with publish plot log
  )
)

;set bulletin board for standard file open
;when publish is called bulletin board is
;updated to run reactor on all files, reset on end
(defun fc:cmd-Publish ( / )
  (vl-bb-set 'bb-Publish "0")
)

 

I've modified the orginal code to trigger a call to load your lisp routine ... make sure the code is placed in a routine that is loaded into each drawing and make sure your plot log routine is in a recognized support path or modify the pathing (ie, c:\\file_path\\lisp\\PLOT_log.lsp).

 

I would recommend that you run a few tests to make sure you are getting what you expect. Let me know if you run into any issues and I'll try to work through them with you.

Message 10 of 13
hcanas
in reply to: rmiller1973

Thank you "rmiller1973" for your respond.

I did that change before, and I get recorded only the first drawing.

 
DC
Message 11 of 13
hcanas
in reply to: hcanas

 
DC
Message 12 of 13
hcanas
in reply to: hcanas

Thank you "rmiller1973", I fix my mistake.

 

It work!! But I have the following problem.

 

If a print 2 dwgs and I need 2 copies from each, it record only the original 2.

 

Any ideas?

 

Please , thank you very much for your help.

DC

DC
Message 13 of 13
hcanas
in reply to: hcanas

 

Hello everybody:

some one can help me to get the amount of copies that have been printed and sent it to the text file within the Publish reactor...

 

thank you in advamce to take time and help me...

 

DC

DC

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost