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

Using macro parameter contains space (changing layer color from command line)

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Zoltan78
1619 Views, 5 Replies

Using macro parameter contains space (changing layer color from command line)

Greetings!

 

I need some help. I'd like to change a layer's color from command line because of a user icon. I figured out from previous topics that I should use macro similar to this: ^C^C_filedia;0;-la;s;Verdeckt (ISO);c;1;l;dashed;;_filedia;1;re;

 

(I want to use this macro to change layer's linetype, too, but that's not the point)


The only problem with this macro: layer's name contains a space therefore Autocad tries to recognize Verdeckt as a command (and macro interrupts there) instead of setting Verdeckt (ISO) as the current layer. I've tried using different quote marks, none of them worked (' and " and <>). I hope there's a method for entering a parameter that contains space. Any idea?

 

Thanks in advance,

Zoltan

Software: Product Design & Manufacturing Collection
OS: Windows 10 Professional x64
CPU: Core i5-8600K
RAM: 2*8Gb
VGA: GTX 3070
5 REPLIES 5
Message 2 of 6
bhull1985
in reply to: Zoltan78

Wrap it in a defun and call it a lsp.

 

(defun c:laychg ( /)

(command "filedia" 0)

(command "._layer" s "Verdeckt" c 1 l "dashed")

(command "filedia" 1)

(command "regen")

)

 

Then in your CUI it'll read like this in the macro section :

^C^C(load "Y:/Path/laychg.lsp");laychg;

 

Which is pathed to fully, so as to ensure it loads. Then it simply loads and executes the commands in the defun. Hopefully that'll work for you.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 3 of 6
Zoltan78
in reply to: bhull1985

It might work but I found the solution. Quote marks do work, I was only trying in command line. I've inserted the whole line in the macro field and it works like a charm.

 

Just for the record:

^C^C_-la;c;1;"Verdeckt (ISO)";c;6;"Bemaßung (ISO)";l;dashed;"Verdeckt (ISO)";;ltscale;20;re;

 

Anyway, thank you!

Zoltan

Software: Product Design & Manufacturing Collection
OS: Windows 10 Professional x64
CPU: Core i5-8600K
RAM: 2*8Gb
VGA: GTX 3070
Message 4 of 6
bhull1985
in reply to: Zoltan78

Oh yes, definitely the " quotes will work for taking care of spaces in the strings but it appeared as if that was not the case for you, so I thought outside of the macro box....

Anyways, now you know how to tie lisps into them if ever needed though (if you're dabbling now with CUI and learning macros, it shouldn't be long before you're toying with lisp either IMO, and lisp with macros like this allow for some very nice time-saving)

 

Keep in mind that all the super-powerful-impressive cad add-ons, such as bentley autoplant, cadworx......are primarily LISP files mixed in with .NET files mixed in with .MNL and GUIs  .....some VBA too im sure somewhere but it's mainly just the other eschelon of complexity but using the same tools and options we've available as users.

 

What I'm saying there is that it'd be good to get familiar with multiple languages that are used in autocad. Not enough to know how to use all of them but would be useful to at least be able to *recognize* them for which one they are, perhaps.

 

Food for thought

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 5 of 6
Zoltan78
in reply to: bhull1985

I haven't needed LISP yet, but who nows... maybe one day I will need it and yes, now I know how to tie lisps into them. I also know there's a slight difference between command line and macro interpreter 🙂

Zoltan

Software: Product Design & Manufacturing Collection
OS: Windows 10 Professional x64
CPU: Core i5-8600K
RAM: 2*8Gb
VGA: GTX 3070
Message 6 of 6
bhull1985
in reply to: Zoltan78

Spoiler
 

Yes Indeed that's correct!

Glad I could help.

The great thing about autoLISP , or these macros within .CUIx, is that there are an abundant amount of users with a plethora of knowledge, and that knowledge is not guarded jealously. These forums are a great central location of autocad knowledge, of any sort. I've gotten bored once or twice and ended up browsing through the threads in this particular forum...there's seemingly an infinite number of them and the threads from way back when are relevant now. (As long as they're using lisp or other currently supported methodology)

Cheers!

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!

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

Post to forums  

Autodesk Design & Make Report

”Boost