PDA

View Full Version : Acaddoc.lsp routine "if" test for loading aeccland.lin


09silverado
2008-06-26, 09:26 PM
i need to do an "if" expression to determine "if" the linetypes called "TREELINE_R", "TREELINE_L" & "STONEWALL" are loaded into every drawing i open.

Then, if they exist i want to reload them.

If they do not exist i want to load them for the first time. here is the code i have to date in my acaddoc.lsp file but it is automatically activating the _help command for some reason, can somebody check this code out? thanks



;loads the aeccland tree lines to your drawing
(command "-linetype" "load" "TREELINE_R" "AeccLand.lin" "" "")

(command "-linetype" "load" "TREELINE_L" "AeccLand.lin" "" "")

(command "-linetype" "load" "STONEWALL" "AeccLand.lin" "" "")


the reason i have the double quotes, is because when the linetypes exists it prompts to determine if you want to reload them, so i put in a "" to act as an "enter" for "yes" and then another "" to exit the routine.

Opie
2008-06-26, 09:28 PM
Check the LTYPE table with the tblsearch function.

09silverado
2008-06-26, 09:31 PM
so here some similar code to see if layers exist but i'm not sure if that is right either and where to put LTYPE in the routine, where do i put that phrase? thanks!



(if (tblsearch "LAYER" "defpoints");;test if layer exists
(command "-layer" "thaw" "defpoints" "on" "defpoints" "") ;do this if exists
(command "-layer" "n" "defpoints" "c" "63" "defpoints" "");do this if not
)



code that needs work:


;loads the aeccland tree lines to your drawing
(command "-linetype" "load" "TREELINE_R" "AeccLand.lin" "" "")

(command "-linetype" "load" "TREELINE_L" "AeccLand.lin" "" "")

(command "-linetype" "load" "STONEWALL" "AeccLand.lin" "" "")

Opie
2008-06-26, 09:35 PM
(foreach n '('("TREELINE_R" "AeccLand.lin")
'("TREELINE_L" "AeccLand.lin")
'("STONEWALL" "AeccLand.lin")
)
(if (tblsearch "LTYPE" (car n))
(command "-linetype" "load" (car n) (cadr n) "")
)
)

09silverado
2008-06-26, 09:38 PM
pure genius.



bows down to master, princ


EDIT
OOOOH, wait, I tried that on a blank template supplied in the "templates" folder from autodesk and it did not load the linetypes? did i miss something?

i copied it just like you pasted it above, do i have to put your code after mine someplace?

09silverado
2008-06-26, 09:45 PM
See message above, i edited my post but wasn't sure if emailed you so i posted again, for some reason it isn't loading the linetypes when they do not exist in, say, a blank drawing.

I probably missed something there, do i need to add your code to mine some how your just replace mine with yours?

Opie
2008-06-26, 10:20 PM
See message above, i edited my post but wasn't sure if emailed you so i posted again, for some reason it isn't loading the linetypes when they do not exist in, say, a blank drawing.

I probably missed something there, do i need to add your code to mine some how your just replace mine with yours?
You asked for it to reinsert the linetypes if they were already loaded. Are the linetypes loaded in the blank template?

09silverado
2008-06-26, 10:31 PM
mmmm.... no, the blank templates and many drawings do not have or use all linetypes from our .lin files. I guess i should load all the linetypes into each MMI template. You did what I asked for, but i forgot to ask you to load them if they didn't exist like my layer example does, which i think works??? It works on drawings but i doubt the code is great on that.

past princ, defun, and a few other code lingo is all i got, and i can read through the routine i just don't understand what forevery n is and cadr is, etc. i'm ignorant... but getting better. I guessed that n was "instance" and that you are using '(' as the search item?

anyways:
i'd like to silent load my MMI.lin file and a few aeccland.lin also, i could go and re-insert the tree linetypes and stone wall from aeccland.lin into my MMI.lin file if that makes this easier....

i know this is a catch 22, because purge is a favorite for drawing cleanup, but if i can force load linetypes then I don't have to worry about ignorant people looking for stuff that experts purge out. We have 45 people pulling licenses in 5 different states, so it's hard to keep track.

if this is a big deal, don't worry about it. I just really wanted to have the linetypes reloaded if they existed like you did... but since i cought your ear :):):)

Opie
2008-06-26, 10:36 PM
Then take out the if statement and just reload the linetypes.
(foreach n '('("TREELINE_R" "AeccLand.lin")
'("TREELINE_L" "AeccLand.lin")
'("STONEWALL" "AeccLand.lin")
)
(if (tblsearch "LTYPE" (car n))
(command "-linetype" "load" (car n) (cadr n) "")
)
)

Remove the items in blue.

09silverado
2008-06-26, 10:45 PM
can't see the red and i KNOW i'm not color blind, lol.

Opie
2008-06-26, 11:11 PM
can't see the red and i KNOW i'm not color blind, lol.
Remove the items in blue then.

09silverado
2008-06-26, 11:14 PM
color isn't working how do i get it to display your highlights?

Opie
2008-06-26, 11:19 PM
Do not remove this
(foreach n '('("TREELINE_R" "AeccLand.lin")
'("TREELINE_L" "AeccLand.lin")
'("STONEWALL" "AeccLand.lin")
)
Remove this
(if (tblsearch "LTYPE" (car n))
Not this

(command "-linetype" "load" (car n) (cadr n) "")

Remove this
)
Not this

)

Does that help?

09silverado
2008-06-27, 01:34 PM
yes, thanks again!