Jump to content

Block library - Tool palettes


Drwo

Recommended Posts

This is the tool palette system I am currnetly trying to implement.

Im posting it here for two reasons.

1. It might be usefull to someone else.

2. Perhaps someone will find some unnoticed mistakes.

 

The tool palettes are linked to drawings on a network drive.

A new profile is created based on the existing one to resovle the problem of preexisting user profiles

The tool palettes are installed by setting the ACAD search path to the catalog files location

The groups are installed by copying the profile.aws file

A toolbar is created for changing tool palette groups.

The toolbar is installed by setting an enterprise cui file.

And the installation process is done through a bat file with the following structure.

 

BAT File

|

Runs ACAD With switch for script

|

Script - Loads a script for profile creation command (with check for existing script)

| - Creates new SMS profile

| - Defines enterprise file path

| - Defines tool palette path

| - Reload workspace

| - Open Block Toolbar

| - Saves workspace

| - sets the insertion units to milimetres

| - Closes AutoCAD

|

COPY - creates a backup of the original profile.aws (only the first time)

| - Copy over precreated profile.aws

|

Start AutoCAD w. switch

 

 

 

So far I have encountered three problems and resolved them which need to be know to better understand the code.

 

1. In some cases users had their systems updated from ACAD 2006 to 2009 with the folders remaining in which case the bat file would end because it would enter the wrong folder

- This was resolved by making the system look for specific AutoCAD verions instead of wildcard folders

 

2. Some of the users had their own profile created in which case the profile.aws would be copied to the > folder and would have no use.

-This was resolved by saving the current profile under a new fixed name and setting the bat file to copy to that folder.

 

3. Some of the users had their insert unit set to inches which would recalculate my unitless tool palettes.

- This was resolved by forcing the insert unit to milimetres inside the installation script.

 

 

Hope someone finds this usefull I've done quite a bit of research. A lot of it on this forum and most of the scripts were taken from other sources.

Link to comment
Share on other sites

BAT File

 

ECHO OFF
cls
c:
CD %PROGRAMFILES%
CD AutoCA*08
CD AutoCA*09
CD AutoCA*10
acad.exe /b "G:\Isme\STS\DRAFTING\AUTOCAD_TOOLS\Library\Blocks_2010\Installation\install.scr"
CD %APPDATA%\AUTODESK
CD AutoCA*08
CD AutoCA*09
CD AutoCA*10
CD R*
CD ENU
CD SUPPORT
CD PROFILES
CD SMS
rename profile.aws profile.bak
copy /Y "G:\Isme\STS\DRAFTING\AUTOCAD_TOOLS\Library\Blocks_2010\Installation\2008+\Profile.aws" .
CD %PROGRAMFILES%
CD AutoCA*08
CD AutoCA*09
CD AutoCA*10
acad.exe /b "G:\Isme\STS\DRAFTING\AUTOCAD_TOOLS\Library\Blocks_2010\Installation\greet.scr

 

 

Install script

 

(alert "* SMS Standard block tool palettes will now be created\n\n* Please do not interrupt the process\n\n* AutoCAD will automatically restart at the end of the process and you will be notified when the installation process is complete")
(vl-load-com)
;retrieve the profiles collection
(setq acadprofiles 
(vla-get-profiles 
 (vla-get-preferences 
  (vlax-get-Acad-Object))))
;get the active profile
(setq actprofile 
(vla-get-ActiveProfile acadprofiles))
;check "SMS" is the active profile
(if (not (= actProfile "SMS"))
 (progn
   ;if it's not, copy the existing profile, renaming it "SMS".
   (vlax-invoke-method acadProfiles 'CopyProfile actProfile "SMS")
   ;then make it the active profile
   (vla-put-ActiveProfile acadProfiles "SMS")
 );progn
);if
(load "G:\\Isme\\STS\\DRAFTING\\AUTOCAD_TOOLS\\Library\\Blocks_2010\\Installation\\install.lsp")
test00
(vla-put-enterprisemenufile (vla-get-files (vla-get-preferences(vlax-get-acad-object)))"G:/Isme/STS/DRAFTING/AUTOCAD_TOOLS/Library/Blocks_2010/Installation/Standard_001.cui")
(command "*_TOOLPALETTEPATH" "G:/Isme/STS/DRAFTING/AUTOCAD_TOOLS/Library/Blocks_2010/PALETTE SYSTEM")
(command "workspace" "c" "SMS")
(command "-toolbar" "STANDARD BLOCKS" "SHOW")
(command "insunits" "4")
(command "quit" "y")

 

 

 

Workspace Lisp

 

(defun c:Test00 (/)
 (command "_.workspace" "_sa" "SMS")
 (while (eq (logand 1 (getvar 'cmdactive)) 1) (command "_Y"))
 (princ)
)

 

 

Greet Script

 

(alert "* The installation process is now complete\n\n* Use the Standard block toolbar to switch between tab groups\n\n* To import blocks select a block and use left click to define the import location")
(alert "* For further reference please adress the Tool palette Technical notes\n\n")

Link to comment
Share on other sites

Now onto the methods for creating reference drawings for the blocks database....

 

A good reccomendation is to keep the main outline of the block objects on layer zero with colour by layer. This way when inserted the blocks will take on the properties of the current layer.

 

To set all layers in a drawing including inside a block you can use this code:

 

(defun c:fixblocks( / b1 name ent elist a8 a62)
 (setq b1 (tblnext "BLOCK" t))
 (while b1
   (princ (strcat "\n" (setq name (cdr (assoc 2 b1)))))
   (setq ent (tblobjname "block" name) ent (entnext ent))
   (while ent
     (setq elist (entget ent))
     (setq elist (if (setq a8 (assoc 8 elist)) (subst (cons 8 "0") a8 elist)))
     (setq elist (if (setq a62 (assoc 62 elist)) (subst '(62 . 0) a62 elist)))
     (setq elist (entmod elist))
     (setq ent (entnext ent))
     )
   (setq b1 (tblnext "BLOCK"))
   )
 (princ)
 )

 

Now if the blocks have other layers like centerlines, invisible lines etc a different method can be employed.

I would isolate the layer that I want to change and open block by block (tedious yes... ) and use cui to associate a set to layer 0 code to a shortcut key

 

^C^C(command "layer" "set" "0" "" "laycur" "all" "" "bclose" "save")

 

 

And finally to avoid scaling errors two steps should be made.

 

1. Set all of your created blocks to unitless. The following script cean be used to complete the task.

 

(vl-load-com)
(vlax-for x
(vla-get-Blocks
(vla-get-activedocument 
(vlax-get-acad-object)))
(vlax-put-property x "Units" 0))
(setvar "insunits" 0)
(setvar "insunitsdeftarget" 0)
(setvar "insunitsdefsource" 0)

 

 

2. Create a tool that can do the same thing in AutoCAD since some drawings come with embedded setting for insertion scale.

 

I used the following script and added it as a tool to the toolbar for switching tool palette groups.

^C^C(command "insunits" "4")
(command "insunitsdefsource" "4")
(command "insunitsdeftarget" "4")

 

 

 

*** ONCE AGAIN I TAKE NO CREDIT FOR ANY OF THE CODES.. I JUST JUMBLED THEM TOGETHER AND AM TRYING TO PROVIDE THEM FOR OTHERS IN ONE NEAT BUNDLE***

Link to comment
Share on other sites

And finally in order to use tool palettes by changing the search path in AutoCAD catalog files must be created for the tool palettes. Since this is not a very intuitive process I'll write down the one I found and used.. note that a simpler method may probably be used but I have done no testing.

 

1. Define a new, familiar path for the tool palettes.. doesn't have to be the one you plan to use on the network

 

2. Create the tool palettes or import the tool palette export files *.xtp

 

3. Save the drawing thats currently open (blank one probably), and close all active drawing but keep AutoCAD open.

 

4. Open new drawing

 

AutoCAD should have created a main catalog file and separate catalog files in a subfolder named PALETTES, and within that subfolder another subfolder named IMAGES which contains all of the block icons.

 

To protect the palettes from changes set the main catalog file to read only. It is good practice to give read only access to all other users to those files. Since when you want to modify something and remove the read-only property all of the other users currently working with your tool palettes can make changes accidentaly.

 

 

 

*** NOTE***

 

That although the catalog files need not be created on the network location the reference drawings must be on the final network location since the catalog files point to them

 

***NOTE***

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...