Jump to content

How to detect if a dimstyle is loaded and load if it isn't


Recommended Posts

Posted

I have a routine that calls a specific dimstyle. However, I am finding that I need to expand the lisp. The lisp sets a specific dimstyle based on either a linear dim or a leader. What I need to add is some error checking. Specifically, check to see if both styles are loaded in the drawing and if not, then load them. I don't know the lisp code needed to do this. Can someone help? Thanks.

Posted

To check if a DimStyle is loaded:

 

(tblsearch "DIMSTYLE" "YourDimStyle")

 

Hence in an IF statement:

 

(if (not (tblsearch "DIMSTYLE" "YourDimStyle"))
   .. Load it ..

Posted

Thanks Lee. I see how to detect if a dimstyle is loaded. But what is the code to load it?

Posted
I have a routine that calls a specific dimstyle. However, I am finding that I need to expand the lisp. The lisp sets a specific dimstyle based on either a linear dim or a leader. What I need to add is some error checking. Specifically, check to see if both styles are loaded in the drawing and if not, then load them. I don't know the lisp code needed to do this. Can someone help? Thanks.

 

Perhaps you should add both of them to your TOOLBOX so that they both autoload.

Posted

They do autoload. The problem is when someone removes the dimstyle from a drawing. I would like the ability to detect if the dimstyles are indeed loaded, which I have, and if not then load them automatically. I'm just not sure the code involved to load it. If someone knows how, I would appreciate it.

Posted

I keep all our dim/text/multileader styles in a dwg that I insert on startup for each drawing. That way, if the drawing is purged and a style is missing, you only have to reload the drawing to get all styles back.

 

eg.

(command "_.-insert" "BlockName=" nil)

This will insert the block definition (all styles and layers within drawing) but cancel (the nil) before given the chance to insert an actual block reference. The "=" at the end of the block name will ensure to overwrite any existing definition - not necessary, but good practice and I like to cover all bases.

I also immediately purge the block, but that isn't really necessary - also covering my bases.

Posted
I keep all our dim/text/multileader styles in a dwg that I insert on startup for each drawing. That way, if the drawing is purged and a style is missing, you only have to reload the drawing to get all styles back.

 

eg.

(command "_.-insert" "BlockName=" nil)

This will insert the block definition (all styles and layers within drawing) but cancel (the nil) before given the chance to insert an actual block reference. The "=" at the end of the block name will ensure to overwrite any existing definition - not necessary, but good practice and I like to cover all bases.

I also immediately purge the block, but that isn't really necessary - also covering my bases.

 

I include all of that on my template, as well as my preferred Table styles, layers and their attributes too. Hit the ground running.

Posted
I include all of that on my template, as well as my preferred Table styles, layers and their attributes too. Hit the ground running.

As do I, but this protects my users from a situation where a style is purged or they open a drawing started by someone else. No matter what, each time they open a drawing, it will ALWAYS have all our company styles.

Posted
As do I, but this protects my users from a situation where a style is purged or they open a drawing started by someone else. No matter what, each time they open a drawing, it will ALWAYS have all our company styles.

 

There's much to be said for consistency, and ALWAYS is pretty much as consistent as it gets.

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...