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

Create Layer and Dimstyle IF they do not exist

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
m_rogoff
1130 Views, 4 Replies

Create Layer and Dimstyle IF they do not exist

Hi, I need a macro to contain the following: (if does not exist) Make Layer "S-DIM", Color 1, set current, (if does not exist) Make Dimstyle "S-DIM12", set current.

 

If S-DIM, S-DIM12 do exist, set current

 

 

Thanks

4 REPLIES 4
Message 2 of 5
hmsilva
in reply to: m_rogoff


@m_rogoff wrote:

Hi, I need a macro to contain the following: (if does not exist) Make Layer "S-DIM", Color 1, set current, (if does not exist) Make Dimstyle "S-DIM12", set current.

 

If S-DIM, S-DIM12 do exist, set current


Hi m_rogoff,

just a starting point:

 

To the

"(if does not exist) Make Layer "S-DIM", Color 1, set current. If S-DIM do exist, set current"

you can use something like this

 

(command "_.layer" "_T" "S-DIM" "_M" "S-DIM" "_U" "S-DIM" "_C" "1" "" "")

 

To the

"(if does not exist) Make Dimstyle "S-DIM12", set current. If S-DIM12 do exist, set current"

perhaps something like this

 

(if (tblsearch "DImstyle" "S-DIM12")
(command "-dimstyle" "_R" "S-DIM12")
(command "_.dim" "DIMADEC" "0";; Angular decimal places
	 "DIMALT" "Off";; Alternate units selected
	 ;; add all the necessary variables to your dimstyle...
	 "save"	"S-DIM12";; to save your dimstyle and become current
	 "exit");; to exit the command
);; if

 

If you don't want to use the command function, you can entmake the new layer or the new dimstyle, or use VisualLISP, or...

 

Hope that helps

Henrique

 

EESignature

Message 3 of 5
m_rogoff
in reply to: hmsilva

Henrique,

Thanks for the suggestions. I am running Acad LT and need it in macro. Does this routine need a deisel expression? The first one is easy to convert to a macro.

Should I write the code to make a new dimstyle everytime, or is there a way (in macro) to use th IF statement? Thanks

Message 4 of 5
hmsilva
in reply to: m_rogoff


@m_rogoff wrote:

Henrique,

Thanks for the suggestions. I am running Acad LT and need it in macro. Does this routine need a deisel expression? The first one is easy to convert to a macro.

Should I write the code to make a new dimstyle everytime, or is there a way (in macro) to use th IF statement? Thanks


You're welcome, m_rogoff

 

using Lt you can't use Autolisp, you can use an if statement, but I don't see a way to do a tblsearch in a macro...maybe someone else may have another solution...

 

Henrique

EESignature

Message 5 of 5
cncah
in reply to: m_rogoff

I don't know about the dimension style but if you use the layer command and use the "make" option it will automatically set it current if it exists and if it does not exist it will create it and then set it current. If the dimension style is stored as one one of your default styles in your templates it is just a matter of setting it. Or you can you can type -DIMSTYLE <enter> _a <enter> and select a dimension to copy the settings from. Haven't played around with that too much but if you know how to set all the variables for your dimension style at the command line then it is a matter of sitting down with a pad a paper and write step by step what you type in at the command line to create it. Then put that info in the macro. Here is what I used for your layer name. Worked fine for me.

^C^C-layer;_make;S-DIM;_color;1;;;

 

 

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

Post to forums  

Autodesk Design & Make Report

”Boost