Lisp in MNS menu file
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
Lisp in MNS menu file

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
devon
Guest





Posted: Tue Jan 11, 2005 2:30 am    Post subject: Lisp in MNS menu file Reply with quote

Hi,

I am trying to get an "if" statement working in my mns file but not having too much luck.

Basiclly, i am inserting a symbol (block) from a location on the server and I want the "if" statement to go "if no exist, then insert same named block from this other location"

Here is the code I am currently using...
Which get's the block from the expansion of the "libpref"
eg. p:/tools/cad/"

[symbols(dttitle,Detail title)]^C^C(stdins (strcat libpref "lib/stdsym/dttitle"))

Any help would be most appreciated.

Regards,
Devon

Back to top
Tom Smith
Guest





Posted: Tue Jan 11, 2005 3:01 am    Post subject: Re: Lisp in MNS menu file Reply with quote

Quote:
Basiclly, i am inserting a symbol (block) from a location on the server
and I want the "if" statement to go "if no exist, then insert same named

block from this other location"
Here is the code I am currently using...
Which get's the block from the expansion of the "libpref"
eg. p:/tools/cad/"
[symbols(dttitle,Detail title)]^C^C(stdins (strcat libpref
"lib/stdsym/dttitle"))

Personally, I wouldn't do any more inline lisp in the menu than what you
already have. Menus can quickly get cluttered up with a lot of repetitive
lisp, which can become a maintenance issue. For instance, you may want this
same kind of block insertion behavior for other kinds of blocks in other
menu items. I'd move the lisp to an MNL file of the same name.

I'm not really clear on your question, but maybe you want something like
this (untested):

(defun altins (blockname 1stlocation 2ndlocation / filename)
(and
(setq filename
(cond
((findfile (strcat 1stlocation blockname ".dwg")))
((findfile (strcat 2ndlocation blockname ".dwg")))
)
)
(stdins filename)
)
)

Then in the menu you'd call it like:

[symbols(dttitle,Detail title)]^C^C(altins "dttitle" (strcat libpref
"lib/stdsym/") fallbackfolder);

Assuming that fallbackfolder is defined in a manner similar to libpref. I
wonder about the extra folder branches after libpref -- do standard symbols
ever get inserted from anywhere besides the stdsym folder? If not, another
variable would save some repetitive coding, such as:

[symbols(dttitle,Detail title)]^C^C(altins "dttitle" standardfolder
fallbackfolder);

Or perhaps this whole alternate folder scenario could go into the stdins
routine.
Back to top
ECCAD
Guest





Posted: Tue Jan 11, 2005 3:02 am    Post subject: Re: Lisp in MNS menu file Reply with quote

Change:
[symbols(dttitle,Detail title)]^C^C(stdins (strcat libpref "lib/stdsym/dttitle"))
to:
[symbols(dttitle,Detail title)]^C^C(if (findfile (strcat libpref "lib/stdsym/dttitle.dwg"))(stdins (strcat libpref "lib/stdsym/dttitle"))(stdins (strcat libpref "lib/stdsym/other_one")))

----------- remove the line-feeds, make it one long line.

Bob

Back to top
devon
Guest





Posted: Tue Jan 11, 2005 5:44 am    Post subject: Re: Lisp in MNS menu file Reply with quote

Hi,

Thankd for the reply.

I am afraid this is not working correctly.

[symbols(dttitle,Detail title)]^C^C(if (findfile "dttitle")(stdins (strcat projpref (nth project_val projnm_sym) "/drawings/standards/ProjSym/dttitle"))(stdins (strcat libpref "lib/stdsym/dttitle")))

(strcat projpref (nth project_val projnm_sym) "/drawings/standards/ProjSym/dttitle")) is the path to the project directory where "DTTitle" should be.

If not the look here...
(stdins (strcat libpref "lib/stdsym/dttitle")))

So Where am I going wrong?

Thanks
Devon
Back to top
Laurie Comerford
Guest





Posted: Tue Jan 11, 2005 6:27 am    Post subject: Re: Lisp in MNS menu file Reply with quote

Hi Devon,

Copy your code into the VLIDE and step through it there. That way you will
be able to identify where your code is working or not working. Once it is
working you can put it in a Menu.mnl file as a defun and call it from there
wit the MNS file, or copy it back to the MNS file.

--

Regards,


Laurie Comerford
www.cadapps.com.au

"devon" <nospam@address.withheld> wrote in message
news:5313701.1105404301026.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
Hi,

Thankd for the reply.

I am afraid this is not working correctly.

[symbols(dttitle,Detail title)]^C^C(if (findfile "dttitle")(stdins (strcat
projpref (nth project_val projnm_sym)
"/drawings/standards/ProjSym/dttitle"))(stdins (strcat libpref
"lib/stdsym/dttitle")))

(strcat projpref (nth project_val projnm_sym)
"/drawings/standards/ProjSym/dttitle")) is the path to the project
directory where "DTTitle" should be.

If not the look here...
(stdins (strcat libpref "lib/stdsym/dttitle")))

So Where am I going wrong?

Thanks
Devon
Back to top
Tom Smith
Guest





Posted: Tue Jan 11, 2005 7:54 am    Post subject: Re: Lisp in MNS menu file Reply with quote

Thanks Laurie. I neglected to mention the most obvious point about having a big glob of lisp in a menu item. Besides contributing to clutter and making menu maintainenance more difficult, it deprives you of the basic debugging tools that would be useful in getting the thing to work in the first place.
Back to top
devon
Guest





Posted: Tue Jan 11, 2005 8:03 am    Post subject: Re: Lisp in MNS menu file Reply with quote

Thanks to all of you for the assistance.

I have come up with a short term solution from your input and will implement the mnl solution over the coming weeks as time permits.

this was my final outcome...

(if (findfile (strcat projpref (nth project_val projnm_sym) "/drawings/standards/ProjSym/dttitle.dwg"))(stdins (strcat projpref (nth project_val projnm_sym) "/drawings/standards/ProjSym/dttitle"))(stdins (strcat libpref "lib/stdsym/dttitle")))

Regards,
Devon
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
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