Author Topic: Insert every time  (Read 4748 times)

0 Members and 1 Guest are viewing this topic.

Luke

  • Guest
Insert every time
« on: April 25, 2008, 11:18:40 AM »
Is there a way to automagically load a drawing or template every time i open a drawing?


Edit: Inert -> Insert
M-dub
« Last Edit: April 25, 2008, 11:35:08 AM by M-dub »

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Inert every time
« Reply #1 on: April 25, 2008, 11:28:06 AM »
Yes.

Checkout: files that automatically load when a drawing is opened
acaddoc.lsp
custom.mnl
startup suite

Add code in one of these drawing to:
check to see if the block exists.
insert if not.

see?
James Buzbee
Windows 8

Crank

  • Water Moccasin
  • Posts: 1503
Re: Insert every time
« Reply #2 on: April 25, 2008, 01:03:14 PM »
If you want to do this to update blocks: That doesn't work, because the blocks are already defined.
If you want to redefine blocks you need to make wblocks and insert them one by one.
Code: [Select]
(command ".insert" "your_block=" (command))
Vault Professional 2023     +     AEC Collection

Luke

  • Guest
Re: Insert every time
« Reply #3 on: April 25, 2008, 01:10:12 PM »
We have created a new drawing template.  I want my guys to use it.  If they start a new drawing they start with the template. Easy enough.

But if they go into an old drawing they continue using all the old crap that is in there and forget about the new template.  I could easily enough creat a button that they can click to load the new template into the old drawings.  They problem is they won't do it.

So what I am trying to do is figure out a way that regardless of brand new, 1 week old, 2 years old or sent to us by an outside source, when they open a drawing it will have all the layers, line types, blocks, etc, etc as what they will see and use in our typical drawing template.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Insert every time
« Reply #4 on: April 25, 2008, 01:54:13 PM »
Why not take advantage of 2006's Standards plug-in?  You can set it to automatically run when a drawing is opened and fix table stuff like Layers, Textstyles, Dimstyles, etc.
James Buzbee
Windows 8

Luke

  • Guest
Re: Insert every time
« Reply #5 on: April 25, 2008, 02:06:48 PM »
I don't want the warning, prompts, questions, notifications, etc etc.  If they realize it is happening they'll turn it off and back to the original problem.

deegeecees

  • Guest
Re: Insert every time
« Reply #6 on: April 25, 2008, 02:19:03 PM »
Locate your acaddoc.lsp, and append this to it. You'll have to change the "name_of_your_template" to what ever your templates name is.

Code: [Select]
(setq template_setup (ssget "X" '((2 . "name_of_your_template"))))
    (if is4lnatt
        (princ)
        (command "-insert" "name_of_your_template" "0,0" "1" "" "")
    )
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Insert every time
« Reply #7 on: April 25, 2008, 03:25:38 PM »
Maybe this
Code: [Select]
(if (null (ssget "X" '((2 . "name_of_your_template"))))
  (command "-insert" "name_of_your_template" "0,0" "1" "" "")
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

deegeecees

  • Guest
Re: Insert every time
« Reply #8 on: April 26, 2008, 09:54:38 AM »
Fixed a variable I overlooked...

Code: [Select]
(setq template_setup (ssget "X" '((2 . "name_of_your_template"))))
    (if [color=red]template_setup[/color]
        (princ)
        (command "-insert" "name_of_your_template" "0,0" "1" "" "")
    )
)

Luke

  • Guest
Re: Insert every time
« Reply #9 on: April 28, 2008, 08:20:47 AM »
I don't like modifying the out of the box acad items.  Then I have to do it on every machine, and if we have to reinstall than I have to remember to re-do it on that machine.  So we have our lisp and other custom files that we run off the server.  I want to run this off the server with one of our other lisps that currently load on startup.

I have added it to such file but no luck.  Is there additional cod that needs to come before this to help make it work?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Insert every time
« Reply #10 on: April 28, 2008, 08:26:28 AM »
I don't think you can change the template of a drawing when you load an existing drawing, however, you can do it on new drawings.
Now, if you want to make the settings in the new drawing fit a specified setting in a particular template, you can set each of the variables, load specific linetypes, setup textstyles, and adjust layers to fit your needs, however it isn't as simple as inserting an existing template.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Luke

  • Guest
Re: Insert every time
« Reply #11 on: April 28, 2008, 08:31:15 AM »
to create a template I have to first create a drawing.  I have a dwg file saved and a dwt file saved.  Can I not just insert that dwg file?

deegeecees

  • Guest
Re: Insert every time
« Reply #12 on: April 28, 2008, 08:55:04 AM »
I want to run this off the server with one of our other lisps that currently load on startup.

I have added it to such file but no luck.  Is there additional cod that needs to come before this to help make it work?

Take a look at your support file structure, and see if the file that you put the code into is loading first. You may want to move the path of the to the top of the list in Options/Files/Support File Search Path. Or am I not getting your intent?

Luke

  • Guest
Re: Insert every time
« Reply #13 on: April 28, 2008, 09:09:29 AM »
I think you are totally getting my intent. 

Here is what I'm getting when I try what you have suggested...

AutoCAD menu utilities loaded.-insert
Enter name of customization file to load: LCC_ANNOTATION
Enter name of customization file to load: 0,0
Enter name of customization file to load: 1
Enter name of customization file to load:
Enter name of customization file to load:
Enter name of customization file to load:
Enter name of customization file to load:
Command: *Cancel*

deegeecees

  • Guest
Re: Insert every time
« Reply #14 on: April 28, 2008, 09:12:41 AM »
Some questions that will clear things up:

1. What file did you insert the code?
2. How is this file being loaded?

Luke

  • Guest
Re: Insert every time
« Reply #15 on: April 28, 2008, 09:14:57 AM »
1. I inserted the code through a file called Luke.lsp
2. It is inserting through the startup suite, with the path for it being the very first thing in the support path.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Insert every time
« Reply #16 on: April 28, 2008, 09:21:10 AM »
This will add some error checking.
Code: [Select]
(cond
   ((ssget "X" '((2 . "LCC_ANNOTATION")))
     (prompt "\nFile exist in drawing.))
   ((setq file (findfile "LCC_ANNOTATION"))
     (command "-insert" file "0,0" "1" "" ""))
   ((princ "\nError - Could not find file LCC_ANNOTATION"))
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CADaver

  • Guest
Re: Insert every time
« Reply #17 on: April 28, 2008, 09:26:24 AM »
I don't like modifying the out of the box acad items.  Then I have to do it on every machine, and if we have to reinstall than I have to remember to re-do it on that machine.  So we have our lisp and other custom files that we run off the server.  I want to run this off the server with one of our other lisps that currently load on startup.
Looks like it's not finding the file to insert, check the path and name.

You know the files you're talking about above can be located on the network (and read from there) so you need only change it once for everyone?  Makes life a whole lot easier for me.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Insert every time
« Reply #18 on: April 28, 2008, 09:28:20 AM »
to create a template I have to first create a drawing.  I have a dwg file saved and a dwt file saved.  Can I not just insert that dwg file?
Yes you can, however, any settings in the current drawing will not be overridden. i.e. lets presume you have a layer called "stuff" this is what it might look like in the current drawing:
Quote
layer = stuff - linetype = dashed - lineweight = 0.01 - color = yellow - plot = true
then you decide that it no longer suits your purposes, so you change the template to:
Quote
layer = stuff - linetype = dashed2 - lineweight = 0.02 - color = green - plot = true
If you insert the template (or other drawing) it will have no effect on the current settings. The same holds true for textstyles, dimension styles, and system variables. i.e. inserting a drawing will have no effect on the current drawing as the inserted drawing will take on the properties already existing in the open drawing.

You will have to programmatically change the settings by loading a lisp in the acaddoc.lsp or other startup mechanism.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Insert every time
« Reply #19 on: April 28, 2008, 09:29:13 AM »
we added this to the company startup lsp. it creates all of our dimension settings, etc.

Code: [Select]
(defun imdim ()
(progn
(command "-insert" "mbc-dimsetup.DWG" nil)
(command "-purge" "b" "mbc-DIMSETUP" "n")
(prompt "\nMBC DimStyles Successfully Loaded!")
)
)
(imdim)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

deegeecees

  • Guest
Re: Insert every time
« Reply #20 on: April 28, 2008, 09:32:34 AM »
This will throw a status to the command line for checking purposes:

Code: [Select]
(defun luke_temp_ins ()
(if (null (ssget "X" '((2 . "name_of_your_template"))))
  (progn
    (command "-insert" "name_of_your_template" "0,0" "1" "" "")
    (princ "\nTemplate loaded.")
  )
    (princ "\nTemplate already resides in dwg.")
))
(luke_temp_ins)

Luke

  • Guest
Re: Insert every time
« Reply #21 on: April 28, 2008, 09:49:07 AM »
Yes my file is on the server.  I just don't like the idea of messing with anything from the box.  All my custom files have a prefix so they can be easily recognized as ours.

I have tried all the suggestions below, they all seem to not put the file into my drawing.

This is what they all result in in the F2 text box...
Quote
Enter name of customization file to load: LCC_ANNOTATION.dwg

I'm not putting in a customization file, i'm inserting a drawing??

deegeecees

  • Guest
Re: Insert every time
« Reply #22 on: April 28, 2008, 10:01:40 AM »
Put the code in one of the files that you KNOW are loading.

BTW, there are better ways to achieve what you are trying to do.

Luke

  • Guest
Re: Insert every time
« Reply #23 on: April 28, 2008, 10:04:28 AM »
As I try to debug here is what I'm getting...

If I put the lisp and path in my startup suite it does not load the drawing, even though it shows up in the loaded applications tab.

If I manually load the appliaction it does insert the drawing.

I am interested in the better way, I'm just limited in my ability.

Luke

  • Guest
Re: Insert every time
« Reply #24 on: April 28, 2008, 10:11:15 AM »
Saying I am limited in my abilities is an accurate statement, but not applicable.  I guess I was just thinking it would be easy to write a quick little lisp," _Insert" "LCC_ANNOTATION.dwg" "0,0" "1" "" "" , add it to the startup and make sure my support path was correct and poof there you go all good.

Better to say at this point in addition to my limited abilities, my knowledge types of customization and ways to do the customization are significantly lacking.

deegeecees

  • Guest
Re: Insert every time
« Reply #25 on: April 28, 2008, 10:24:33 AM »
If you don't want to modify anything from AC's original state, you are a bit limited to what you can do, however if you feel you can think outside the box *yes, I said it, and all puns are intended*, then you'll be able to achieve a more rigid set of standards.


Luke

  • Guest
Re: Insert every time
« Reply #26 on: April 28, 2008, 10:40:00 AM »
I'm willing to give it a try.

I'm typically pretty head strong and stubborn as to what I want to achieve but I'm flexible on how to get there.

deegeecees

  • Guest
Re: Insert every time
« Reply #27 on: April 28, 2008, 11:13:20 AM »
Here's something to muck around with:

http://www.theswamp.org/index.php?topic=19044.msg232055#msg232055

Using the method mentioned in the link, combined with the Acad.dvb (VBA) and some logical directory structuring, you can enforce most standards programatically. You may want to have an outlined plan before attempting to set things up in this manner. If your programming skills are limited, then I'd suggest doing some research/learning as well.

There are other methods of doing this, as individual ways of thinking provide individualized results, and newer versions of AC provide different solutions too. I just don't want to open up a can of worms here when all you wanted to do was insert a drawing containing your standards.

CADaver

  • Guest
Re: Insert every time
« Reply #28 on: April 28, 2008, 11:30:00 AM »
The modification to the OOTB function like acad2006doc.lsp would be the addition of a loading function to load specific routines like:
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (if (not (load "e:/programs/ac2002/menus/csa/CSA-SETUP.lsp" nil))
  (progn
    (princ "loading error.")
    (princ "\nCSA-SETUP.lsp not found.  CSA Shorthand Commands are not enabled.  ")
  )
)
(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If you point all installations to a network drive for the acad2006doc.lsp and the custom functions, you only have one place to modify to impact all installations.

And has been pointed out, the insertion of a “template” will not change many settings in the current file.  To do that you need a function to programmatically reset them.