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

Check for Pagesetup

2 REPLIES 2
Reply
Message 1 of 3
spm5
352 Views, 2 Replies

Check for Pagesetup

Hello, 

I have a Lisp that will bring up a dialogue and let users pick a page side and will pull in a page setup from a template file. 

It works well except if there is already a pagesetup with the same name in the file. 

What I am looking to do is check if the page setup name exists in the file, and itf it does delete it. 

 

Does anyone know how to do this?

2 REPLIES 2
Message 2 of 3
spm5
in reply to: spm5

I got it. 

for those looking for it:

 

(defun psdel ( / appAcad colPgSetups docCurrent objPgSetup)
(vl-load-com)
(setq appAcad (vlax-get-acad-object)
docCurrent (vla-get-ActiveDocument appAcad)
colPgSetups (vla-get-PlotConfigurations docCurrent)
)
(vlax-for objPgSetup colPgSetups
(if (= (vla-get-name objPgSetup) psname) (vla-delete objPgSetup))
(vlax-release-object objPgSetup)
)
(vlax-release-object colPgSetups)
(vlax-release-object docCurrent)
(vlax-release-object appAcad)
(princ)
)

 

where psname is the name of the pagesetup

Message 3 of 3
Kent1Cooper
in reply to: spm5


@spm5 wrote:

.... 

What I am looking to do is check if the page setup name exists in the file, and itf it does delete it. 

....


[I'm not sure about Page Setups, but I wonder whether you couldn't just delete it, without checking whether it exists already.  I know you can do that with certain other things, such as Views and Layouts.  If the one you ask to delete isn't there, a message goes by that it didn't find one with that name, but it doesn't cause an error, or interfere with anything that follows.]

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost