Edit Dimension Properties or Change Dimension Style

Edit Dimension Properties or Change Dimension Style

Anonymous
Not applicable
4,678 Views
7 Replies
Message 1 of 8

Edit Dimension Properties or Change Dimension Style

Anonymous
Not applicable

Surprisingly, I can't seem to find much on this issue. I would like to change some of the properties of the last dimension that was created in my lsp. The default style is not what I need and should not be changed for this drawing. I only need to change some properties of the few dimensions that I create.

 

If I cannot change the properties, then if it is easier to create an alternate dimstyle in my template and APPLY that to the last dimension drawn, then I am open to that also.

 

Any ideas on how to code this? I'll add some sample code of what I'm looking for. I'm sure it probably isn't so easy. Any help is appreciated!

 

~D

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;Change last dimension properties;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq LastDim (entlast))
(setq MyScale 50.00)
(command "chprop" LastDim "Dim Units" "Decimal" "Dim scale linear" MyScale "")

;;;;;;;;;;;;;;;;;;;;OR Change last dim DimStyle;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq LastDim (entlast))
(command "ChStyle" LastDim "MyStyle")
0 Likes
Accepted solutions (1)
4,679 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

Look into the DIMOVERRIDE command.  You get to specify any number of properties to override, the value to put in each, and [after Enter when done specifying those] finally the Dimension(s) that you want to apply those overrides to.  For example:

 

(command "_.dimoverride" "DIMLUNIT" "2" "DIMLFAC" "50" "" (entlast) "")

Kent Cooper, AIA
Message 3 of 8

Anonymous
Not applicable

Kent,

 

EXACTLY what I was looking for, much appreciated! Thank you.

 

~D

0 Likes
Message 4 of 8

scot-65
Advisor
Advisor
Lets look at it without using ENTLAST.

Assuming the user has successfully selected 3 points for the dim command...

(if (and p1 p2 p3)
(progn
(foreach x (setq a (list "DIMLUNIT" "DIMLFAC"))
(setq b (cons (getvar x) b))
);foreach
(setvar (nth 0 a) 2)
(setvar (nth 1 a) 50)
(command dim... p1 p2 p3 "exit")
;one can use -DIMSTYLE "Restore" method here [and skip the foreach part] or
(setq n 0 b (reverse b))
(repeat (length a)
(setvar (nth n a) (nth n b))
(setq n (1+ n))
);repeat
);progn
);if
;*untested*

This works well when there are 5 or more variables to 'temporarily' set.
The variables to temporarily set would only have to be written once using this structure.
There are other methods to write this...

???

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

Message 5 of 8

Kent1Cooper
Consultant
Consultant

@scot-65 wrote:
....
 (foreach x (setq a (list "DIMLUNIT" "DIMLFAC"))
(setq b (cons (getvar x) b))
);foreach
(setvar (nth 0 a) 2)
(setvar (nth 1 a) 50)
....
(setq n 0 b (reverse b))
(repeat (length a)
(setvar (nth n a) (nth n b))
(setq n (1+ n))
);repeat
 ....
The variables to temporarily set would only have to be written once using this structure.
....

I don't see any advantage to an approach like that.  The code in Post 2 also writes each variable only once.  And because it imposes the value for each property on the selected Dimension(s), without changing the System Variable settings, it doesn't require saving the settings first and resetting them afterwards, which is the main reason for the great difference in the amount of code involved.

 

But if you wanted for some reason to change those settings before drawing the Dimension(s) and restore them afterwards, it can be done more concisely without the (foreach) and (repeat) and (nth) and index-counter elements:

 

(setq
  dimvars '(dimlunit dimlfac) ;; and as many others as desired
  oldvals (mapcar 'getvar dimvars) ;; current settings
); setq
(mapcar 'setvar dimvars '(2 50)) ;; and as many others as desired, corresponding to items in 'dimvars' list
.... draw the Dimension(s) ....
(mapcar 'setvar dimvars oldvals) ;; restore settings

 

In any case, I would be inclined instead to just make a Dimension Style with the desired properties, and use that  to draw the Dimensions, rather than to impose a regular collection of overrides on Dimensions that were drawn using some Style that doesn't  have all the desired properties.  But maybe the OP has some reason for doing it that way that I don't have the imagination to think of....

Kent Cooper, AIA
Message 6 of 8

scot-65
Advisor
Advisor
There are some instances to apply overrides in lieu of creating
totally unique dimension styles. One example is to replace the
architectural tic when applying angular or radius dimensions.

The OP is new to this community and we, as members, provide
insight to view processes more than one way (this example to
bypass commands).

I'm still a little foggy with mapcar (and vla), and did not consider this.
Your snippet has been placed in an ever growing folder of good
ideas found on this forum...

scot-65

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

0 Likes
Message 7 of 8

Kent1Cooper
Consultant
Consultant

@scot-65 wrote:
There are some instances to apply overrides in lieu of creating totally unique dimension styles. One example is to replace the architectural tic when applying angular or radius dimensions.
....

Absolutely.  But I do think that if you have a specific combination of overrides that you use often enough to want to build them into a routine, it may be better to define a Style instead.

Kent Cooper, AIA
0 Likes
Message 8 of 8

Anonymous
Not applicable

You both have provided GREAT input for this. thank you so much. My reason for OVERRIDE in this case is that It is for one template we are using for this project, and I do not have permissions to save over the template. so I would have to create a new dimstyle each time I started a new project with this template (would be frequent). I love the fact of storing the old variables, using new ones and restoring them. It seems much more efficient than using a (COMMAND "DIMOVERRIDE...). Any second spared while running codes is useful. I am new to the game and appreciate all of the useful info! Both of you have provided more than enough for me to chew on and move forward with. Thank you again

0 Likes