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

Update dimension to their current style (Refresh dimensions).

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
3687 Views, 9 Replies

Update dimension to their current style (Refresh dimensions).

Hello Autodesk Community,

 

My objective is to create a lisp routine that updates all dimensions in a drawing according to its current dimstyle settings.

The reason for this is because we have some drawings with dimensions whose dimstylee settings are correct, yet their displays are incorrect.  We found a quick fix by performing the 'DIM1 UPDATE' command.

 

Below are before and after images showing the changes

 

Dimension before updating:Dimension after updating:
Before 'Dim Update'After 'Dim Update'

 

The current lisp routine I'm using to perform the 'DIM1 UPDATE' uses the sssetfirst command to highlight and show the grips for a selectionset containing the dimensions using a particular dimstyle.  Unforutnately, the selection is not recognized by the 'DIM1 UPDATE' command, so the dimensions do not change.

 

Afterwards, I tried passing the 'PREVIOUS' selection after creating the selection set, which appears to have slightly different behaviour, but still does not function properly since the selection is not used.

 

Below is the lisp code for the routine so you can understand what It looks like:

(defun c:DIMREFRESH()
	(setq dimstyle (tblnext "DIMSTYLE" T))
       
        ;;Iterate through the dimstyles (this automatically 
        ;;changes the currently set dimstyle)
	(while (setq dimstyle (tblnext "DIMSTYLE"))  
                
                ;;Get the name of the dimstyle
		(setq styleName (cdr (assoc 2 dimstyle)))
                
                ;;Create a filter for selecting all dimensions using 
                ;;the current dimstyle
		(setq filter (list (cons 3 styleName)))
                
                ;;Apply the filter to a selection set of everything.
		(setq dimensionSelection (ssget "X" filter)) 
                
                ;;If there are dimensions selected, then update them.
		(if (/= dimensionSelection nil)
			(sssetfirst nil dimensionSelection)
			(command "DIM1" "UPDATE" "PREVIOUS" "")
		)
	)
)

 

So, I'm not sure if I am tackling this problem the correct way.  Regardless, I want to know what you guys think might be a solution to this issue.

I would be grateful to learn of other methods that can achieve the same desired result as well.

 

As of now, I have tried to use the "-DIMSTYLE SAVE" command, but this does not change the display, leading me to believe these are not overridden settings

 

Your help is greatly appreciated.

 

God Bless,

Nick

 

9 REPLIES 9
Message 2 of 10
dmfrazier
in reply to: Anonymous

Can you post a (stripped-down) DWG exhibiting this behavior?

Message 3 of 10
scot-65
in reply to: Anonymous

(if (/= dimensionSelection nil)
	(sssetfirst nil dimensionSelection)
	(command "DIM1" "UPDATE" "PREVIOUS" "") )

to

 

(if (> (sslength dimensionselection) 0)

 (command "-DIMSTYLE" "Restore" (cdr (assoc 3 dimstyle)) "Apply" dimensionselection "")

);if

*untested*


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 4 of 10
Anonymous
in reply to: scot-65

@Scot-65,

 

That did the trick!

I guess what I didn't know was that you can pass the selection set as a variable into commands where you can pass in a selection argument.

For example, command likes EXPLODE and MOVE.

 

For commands like BURST, which waits for user input, you need to use the sssetfirst function.

 

I changed the lisp code to use 'DIM1 UPDATE' and I passed the selection set as variable, and the command recognized the selection set.  The only problem with this is that I didn't change the current dimstyle.

 

Here is the new lisp file:

(defun c:DIMREFRESH()
	(setq dimstyle (tblnext "DIMSTYLE" T))
	(while (/= dimstyle nil)
		(setq styleName (cdr (assoc 2 dimstyle)))
		(princ (strcat "LIST: " styleName "\n"))
		(setq filter (list (cons 3 styleName)))
		(setq dimensionSelection (ssget "X" filter))
		(setq ssIndex 0)
		(if (/= dimensionSelection nil)
			(command "-DIMSTYLE" "RESTORE" styleName)
(command "-DIMSTYLE" "APPLY" dimensionSelection "") ) (setq dimstyle (tblnext "DIMSTYLE")) ;Get the next dimstyle ) )

 

 

 

 

Message 5 of 10
Anonymous
in reply to: Anonymous

@dmfrazier,

 

I've attached a dwg exhibiting the bevior describe above.

You can enter the command 'DIM1 UPDATE ALL' to see the changes.

 

Although I have found a solution already, it would still be useful to understand why exactly the dimensions are not displayed consistently with their settings.

Message 6 of 10
dmfrazier
in reply to: Anonymous

"Although I have found a solution already, it would still be useful to understand why exactly the dimensions are not displayed consistently with their settings."

 

If I understand correctly, the basic issue is that the dimensions have dim variable "overrides" that differ from their applied dimension style.  For instance, the dimscale value specified in the TWO_PLACE dim style is 101.6, while each dimension object in the DWG has that variable "overridden" with the value 4.  (Edit: This is easily seen by looking at Properties.)

 

Maybe I'm misunderstanding your objective, but I think there is already a built-in command (in AutoCAD 2013 and maybe prior) that does what you are trying to customize.  If I select all the dims (which could be done with QSelect or Filter) and right-click, one of the options is "Remove Style Overrides".  This runs the DIMOVERRIDE command with the "C" (Clear overrides) option.  This command appears to be available even if the selected dimensions have no overrides or the selection contains a mixture of the two.

 

If your objective is to make this more "automatic", I suppose you could still create a LISP, but it might be a lot easier to use the DIMOVERRIDE command, like so:

(command "dimoverride" "c" "all" "");the command ignores non-dimension objects in the selection set

 

You could also skip LISP altogether and just run it as a macro from a toolbar button, menu pick, etc.

 

Message 7 of 10
Anonymous
in reply to: dmfrazier

@dmfrazier,

 

Okay, I understand now. My original assumption was that the dimensions were not overridden because when I use the '-DIMSTYLE SAVE' command (and save to the same name), the dimensions didn't change.

 

Does this mean that there two types of overrides for dimensions?

One type used to copy/modify the settings an entire dimstyle (which creates a child dimstyle). And the second type used to customize a single dimension beyond the dimstyle it is using?

 

 

 

 

Message 8 of 10
dmfrazier
in reply to: Anonymous

"Does this mean that there [are] two types of overrides for dimensions?  One type used to copy/modify the settings [of] an entire dimstyle (which creates a child dimstyle). And the second type used to customize a single dimension beyond the dimstyle it is using?"

Property (dim var) differences that define a "child" dimstyle are not considered "overrides".  Child dimstyles might be better thought of as "sub-styles", I guess.  You can use overrides to achieve the same effect as defining and applying a child dimstyle, but then modifying the underlying dimstyle will only affect automatically those dim vars that have not been overidden "on top of" the dim style.  To re-apply all the dim vars in the underlying dimstyle, you would have to run DIM UPDATE, which would also remove any overrides.

Does that make sense?

 

Message 9 of 10
Anonymous
in reply to: dmfrazier

Yes, this makes sense. My terminology may have been confusing, but we are agreeing.

Child dimstyles are not called overrides whatsoever. Overrides are simply settings that are unique customizations of a dimstyle for only a particular dimension.
Message 10 of 10
scot-65
in reply to: Anonymous

>> Does this mean that there two types of overrides for dimensions?

 

Overrides are just that - changes to certain dimvars without actually saving what was changed to be part of the dimension style.

 

For instance, I have a dimension style designed for 1/4 scale production (and I have text styles with declared height greater than zero).

If I want to change the style of the dimension for a new drawing scale, I can easily apply two overrides - DIMSCALE and DIMTXSTY.

Now this dimension style with the overrides can be used on a different drawing scale drawing, and the dimensions will look exactly the same.

 

To make this a permanent dimension style, I will need to save the current geometry, with the overrides, but I do not do that.

I allow the overrides be present when I am in another drawing scale, and when I am finished in that other scale drawing, I will:

command "DIM" "Restore" "MyDimstyle" "Exit", which will bring me back to the base 1/4 scale (the overrides are removed).

 

There are about 75 dimvars in R2014 available as overrides.

 

To see some of these, command LIST, and select a dimension that has overrides (or a LEADER object).

 

Another popular dimvar override is DIMLFAC - when a detail is not the same scale (/= 1:1) as the rest of the drawings on a model space page.

 

See documentation Command Reference / System Variables for other dimvars.

 

I hope this makes sense.


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


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

Post to forums  

Autodesk Design & Make Report

”Boost