Jump to content

Recommended Posts

Posted (edited)
;;--------------------------------------------;;
;;--------------------------------------------;;

(if (not FIX:DIMS)
	(setq FIX:DIMS (vlr-command-reactor nil '((:vlr-commandended . FIX:DIMSTYLES)(:vlr-commandcancelled . FIX:DIMSTYLES))))
)

;;--------------------------------------------;;
;;--------------------------------------------;;

(defun FIX:DIMSTYLES (rea lst)
	(if (wcmatch (car lst) "DIM*")
		(progn
			(while (setq dimstyle (tblnext "dimstyle" (not dimstyle)))
				(setq dimstylename (cdr (assoc 2 dimstyle)))
				(command "-DIMSTYLE" "restore" dimstylename)
				(setvar "DIMTMOVE" 1)
				(setvar "DIMTFILL" 1)
				(if (tblsearch "dimstyle" dimstylename)
					(command "-DIMSTYLE" "save" dimstylename "Y")
					(command "-DIMSTYLE" "save" dimstylename)
				)
			)
			(vlr-data-set rea nil)
		)
		(progn
			(vlr-data-set rea nil)
		)
	)
)

;;--------------------------------------------;;
;;--------------------------------------------;;

(princ)

;;--------------------------------------------;;
;;--------------------------------------------;;

 

Hi all,

The code above gives me an error:

AutoCAD command rejected: "-DIMSTYLE"

 

Seems like i cannot execute 'COMMAND' function within a reactor....

Is there a trick to fix this?

 

We use an external third-party tool, that creates DIMSTYLES when the DIMENSION command is begin executed.

Therefor i want to modd the style afterwards.

I cannot control the base settings of the dimstyle in the template OR the third-party tooling.

 

Edited by Aftertouch
Posted (edited)

If you set the dimstyle that you want, all the dimstyle variables can be read by "getvar", I think this is a list of them:

 

[ (variable_Name, new_value) ;; default ;; Description ]

EDIT - list taken from one of my LISPS, not editted but you can get the variable names from this

 (setvar "DIMADEC"  TxtPrecision)  ;; 0       ;;Angular Dimension Decimal Places
;  (setvar "DIMALT"    0)    ;; 0              ;;Control of alternative units 0 - Off 1 - On
  (setvar "DIMALTD"   TxtPrecision)    ;; 2 / 3          ;;Alternative Units Decimal Places
;  (setvar "DIMALTF" 0.0394) ;; 25.4 / 0.0394  ;;Alternative Units Scale Factor
;;(setvar "DIMALTMZF")      ;;                ;;Alternate sub-zero factor for metric dimensions - Unknown variable
;;(setvar "DIMALTMZS")      ;;                ;;Alternate sub-zero suffix for metric dimensions - Unknown variable
;  (setvar "DIMALTRND" 0.00) ;; 0.00           ;;Alternate units rounding value
;  (setvar "DIMALTTD"  3)    ;; 2 / 3          ;;Alternative Units Tolerance Decimal Places
;  (setvar "DIMALTTZ"  0)    ;; 0              ;;Alternate tolerance zero suppression
;  (setvar "DIMALTU"   2)    ;; 2              ;;Alternative Units Units
;  (setvar "DIMALTZ"   0)    ;; 0              ;;Alternate unit zero suppression
;  (setvar "DIMAPOST" "")    ;; ""             ;;Prefix and suffix for alternate text
;  (setvar "DIMARCSYM" 0)    ;; 0              ;;Arc Length Dimension Arc Symbol
  (setvar "DIMASZ" FontHeight) ;; 0.18 / 2.5  ;;Dimension Line and Leader Line Arrow Heads size
;  (setvar "DIMATFIT"  3)    ;; 3              ;;Arrow and text fit if distance is too narrow for both
;  (setvar "DIMAUNIT"  0)    ;; 0              ;;Angular unit format
;  (setvar "DIMAZIN"   0)    ;; 0              ;;Angular Dimension Depresses leading zeros
;  (setvar "DIMBLK"  ".")    ;; "."            ;;Arrow block name "." for closed flled else as properties
;  (setvar "DIMBLK1" ".")    ;; "."            ;;First arrow block name "." for closed flled else as properties
;  (setvar "DIMBLK2" ".")    ;; "."            ;;Second arrow block name "." for closed flled else as properties
  (setvar "DIMCEN" FontHeight) ;; 0.09 / 2.5  ;;Drawing centre mark for radius or diameter dimensions
  (setvar "DIMCLRD" LinCol) ;; 0              ;;Colours - Lines, ArrowHeads, Dimension Lines 0: ByLayer, 256 ByBlock
  (setvar "DIMCLRE" LinCol) ;; 0              ;;Colours - Extension Lines, Centre Marks Colours 0: ByLayer, 256 ByBlock
  (setvar "DIMCLRT" TxtCol) ;; 0              ;;Colours - Dimension Text Colour 0: ByLayer, 256 ByBlock
  (setvar "DIMDEC"  TxtPrecision)  ;; 0       ;;Dimension Decimal Places
;  (setvar "DIMDLE"    0)    ;; 0.0000         ;;Dimension Line extension with oblique strokes instead of arrows
;  (setvar "DIMDLI"    4)    ;; 3.75           ;;Dimension Baseline Dimension Spacing
  (setvar "DIMDSEP" ".")    ;; .              ;;Decimal separator
  (setvar "DIMEXE" (/ Fontheight 2)) ;; 0.18 / 1.25    ;;Extension Line Extension distance
  (setvar "DIMEXO" (/ Fontheight 4)) ;; 0.0625 / 0.625 ;;Extension Line Offset
;  (setvar "DIMFRAC"   0)    ;; 0              ;;Dimension Fraction Format
;  (setvar "DIMFXL" 1.00)    ;; 1              ;;Fixed Extension Line
;  (setvar "DIMFXLON"  0)    ;; 0              ;;Enable Fixed Extension Line 0 - Off 1 - On
  (setvar "DIMGAP" (/ FontHeight 4)) ;; 0.09 / 0.625   ;;Dimension gap between text and arrow 
  (setvar "DIMJOGANG" (* pi (/ 45 180.0))) ;; ;;Radius dimension jog angle.. radians?
;  (setvar "DIMJUST"   0)    ;; 0              ;;Justification of text on dimension line
  (setvar "DIMLDRBLK" ".")  ;; "."            ;;Leader block name "." for closed flled else as properties
;  (setvar "DIMLFAC" 1.00)   ;; 1              ;;Linear unit scale factor
;  (setvar "DIMLIM"    0)    ;; 0              ;;Generate dimension limits 0 - Off 1 - On
  (setvar "DIMLTEX1" "BYBLOCK")    ;;  "."    ;;Linetype extension line 1
  (setvar "DIMLTEX2" "BYBLOCK")    ;;  "."    ;;Linetype extension line 2
  (setvar "DIMLTYPE" "BYBLOCK")    ;;  "."    ;;Dimension linetype
;  (setvar "DIMLUNIT"  2)    ;; 2              ;;Dimension Units (except angular) - number type
;  (setvar "DIMLWD"   -2)    ;; -2             ;;Dimension Line Lineweights
;  (setvar "DIMLWE"   -2)    ;; -2             ;;Extension Line Line Weight
;;(setvar "DIMMZF")         ;;                ;;Sub-zero factor for metric dimensions - Unknown variable
;;(setvar "DIMMZS")         ;;                ;;Sub-zero suffix for metric dimensions - Unknown variable
;  (setvar "DIMPOST" "")     ;; ""             ;;Prefix and suffix for dimension text
;  (setvar "DIMRND"   0)     ;; 0              ;;Dimension Round distance to nearest n
;  (setvar "DIMSAH"   0)     ;; 0              ;;Separate arrow blocks 0 - Off 1 - On
;  (setvar "DIMSCALE" 1)     ;; 1              ;;Dimension Scale Factor
;  (setvar "DIMSD1"   0)     ;; 0              ;;Suppress the first dimension line 0 - Off 1 - On
;  (setvar "DIMSD2"   0)     ;; 0              ;;Suppress the second dimension line 0 - Off 1 - On
;  (setvar "DIMSE1"   0)     ;; 0              ;;Suppress the first extension line 0 - Off 1 - On
;  (setvar "DIMSE2"   0)     ;; 0              ;;Suppress the second extension line 0 - Off 1 - On
;  (setvar "DIMSOXD"  0)     ;; 0              ;;Suppress outside dimension lines
;  (setvar "DIMTAD"   0)     ;; 0              ;;Dimension Text Vertical distance
;  (setvar "DIMTDEC"  4)     ;; 4              ;;Tolerance decimal places
;  (setvar "DIMTFAC"  1)     ;; 1              ;;Dimension text scale factor of fractions relative to text height
;  (setvar "DIMTFILL" 0)     ;; 0              ;;Text background enabled
;  (setvar "DIMTFILLCLR" 0)  ;; 0              ;;Text background color 0: ByLayer, 256 ByBlock
;  (setvar "DIMTIH"   0)     ;; 0              ;;Text inside extensions is horizontal 0 - Off 1 - On
;  (setvar "DIMTIX"   0)     ;; 0              ;;Place text inside extensions 0 - Off 1 - On
;  (setvar "DIMTM"    0)     ;; 0              ;;Dimension Minus tolerance distance when used with dimtol, or dimlim
;  (setvar "DIMTMOVE" 0)     ;; 0              ;;Text movement
;  (setvar "DIMTOFL"  0)     ;; 0              ;;Force line inside extension lines 0 - Off 1 - On
;  (setvar "DIMTOH"   1)     ;; 1              ;;Text outside horizontal 0 - Off 1 - On
;  (setvar "DIMTOL"   0)     ;; 0              ;;Tolerance dimensioning 0 - Off 1 - On
;  (setvar "DIMTOLJ"  1)     ;; 0              ;;Tolerance vertical justification
;  (setvar "DIMTP"    0)     ;; 0              ;;Dimension Plus tolerance distance when used with dimtol, or dimlim
;  (setvar "DIMTSZ" 0.00)    ;; 0              ;;Tick size
;  (setvar "DIMTVP" 0.00)    ;; 0              ;;Text vertical position
  (setvar "DIMTXSTY" FontName)     ;; Font    ;;Text style
  (setvar "DIMTXT" FontHeight)     ;; 0.18 / 2.5   ;;Dimension text Height
;;(setvar "DIMTXTDIRECTIONOff" 0)  ;;         ;;Dimension text direction 1 or 0 - NOT SURE IF THIS WORKS
;  (setvar "DIMTZIN"  8)     ;; 8              ;;Suppresses leading zeros in tolerance values
;  (setvar "DIMUPT"   0)     ;; 0              ;;User positioned text 0 - Off 1 - On
;  (setvar "DIMZIN"   8)     ;; 8              ;;Suppresses leading zeroes

 

 

if not I think BigAl had a list somewhere too - might be an alternative way to get what you want?

Edited by Steven P
Posted

@Steven P

Thanks for the reply.

Above is 'just an example'.

I cannot seem to be able to execute any command, when its part of the reactor.

Also (command "UCS" "W") is not working.

 

not specificly looking for the DIM settings, but a way to be able to execute a command after another command...

Posted

Hi,

You can not use command calls with reactors , here is a working function.

(defun FIX:DIMSTYLES ( rea lst )
  (if (wcmatch (car lst) "DIM*")
    (progn
      (or *TH:doc* (setq *TH:doc* (vla-get-activedocument (vlax-get-acad-object))))
      (vla-put-ActiveDimStyle *TH:doc* (vla-item (vla-get-dimStyles *TH:doc*) "STATUS"))
      (vlr-data-set rea nil)
    )
    (vlr-data-set rea nil)
  )
)

I am wondering why did not you use call back: VLR-commandWillStart within your reactor !

Posted

@Tharwat and @Steven P

Sorry for the confusion.

I edited the first post with the full code.

 

What im looking for:

We use a Third-party tool that creates DIMSTYLES when a DIM-command is executed.

The styling is wrong, and i want to edit this after creation.

Therefor i need a commandended reactor, to be able to manipulate the styling after creation.

Posted

I guess you can't edit the 3rd party tool? What happens if you set the DIM style as you want one time and then afterwards make a dimension, will the 3rd party tool modify the existing dimension style?

 

Asking because you could do this without the reactors, normal LISP to set up the dimensions or modify them when you open a drawing or as and when you need to. Several ways in LISP to do the same thing, s if 'commands' don't work can you do it with LISP commands or VLA? I don't use reactors really so not sure about this

Posted

@Steven P unfortunately i cannot edit the Third-Party tool... That would be a relief.🤣

When the user starts a drawing, and creates a dimension, the style is created.

Due to the possible settings, the style name can be a variation of 50 different styles....

I dont want the user the do something manualy everytime a new style is created.

They shouldnt even notice that i modify the default settings. 😁

 

So my idea was to do a quick override everytime a dimension is placed. Since i cannot use a reactor when a new dimstyle is created... wel... not that i know of..

Im open for all suggestions ofcourse. Main goal is to fix this in 'my' engine, without the user noticing.

  • Like 1
Posted

So what would happen if you set the style when the drawing was opened and then create a dimension, will this modify what you set before to the 3rd party dimension style? If that works create the styles with a template or a LISP that runs on loading - I have one that could be modified to do that I think, 

Posted
4 minutes ago, Steven P said:

So what would happen if you set the style when the drawing was opened and then create a dimension, will this modify what you set before to the 3rd party dimension style? If that works create the styles with a template or a LISP that runs on loading - I have one that could be modified to do that I think, 

Hi @Steven P, i have good code that could set up a template. I used to have a temlate with all styles. This is a workaround and creates many unused styles in the template. Wich van get lost when purging.

 

would realy like to be able to manipulate after the creation.

Posted (edited)

Last option though not a favourite would be to create your own 'dimension' lisp using the same commands as usual, so the user would say type "dim" which would call the command 'dim' - as usual but as this LISP ends it can run another code without the user realising to set any existing dim styles to the styling you like (noting that the ISP will be loaded after 'dim' and so take precedence)

Edited by Steven P
Posted (edited)

As Steven hinted you could make a FIXDIM function that looks for dims and resets some of the properties to suit what you want. That way you use the 3rd party DIM command, then fix.

 

It would be easier than trying to build a reactor, that would do the same as FIXDIM.

 

Can you just click the Dim and change its style name in Properties does that fix it ? Thats an easy code.

 

I think need a dwg with a 3rd party Dim and a what you want Dim. Including any dim styles etc. 

Edited by BIGAL
Posted

@Steven P, @Tharwat, @BIGAL

 

ITS ALIVE

It IS possible to launch a commando with a reactor.

It was a long day... but i got it working! 🙂

;;--------------------------------------------;;
;;--------------------------------------------;;

(if (not FIX:DIM)
	(setq FIX:DIM (vlr-command-reactor nil '((:vlr-commandended . DIM:RESTORE)(:vlr-commandcancelled . DIM:RESTORE))))
)

;;--------------------------------------------;;
;;--------------------------------------------;;

(defun DIM:RESTORE (rea lst)
	(if (vl-position (car lst)'("DIMLINEAR" "DIMALIGNED"))
		(progn
			(vla-sendcommand (vlr-document rea)(strcat "(FIX:DIMENSIONSTYLES) "))(princ)
		)
	)
)

;;--------------------------------------------;;
;;--------------------------------------------;;

(defun FIX:DIMENSIONSTYLES ( / oldcmdecho )
	(setq oldcmdecho (getvar "CMDECHO"))
	(setvar "CMDECHO" 0)
	(while (setq dimstyle (tblnext "dimstyle" (not dimstyle)))
		(setq dimstylename (cdr (assoc 2 dimstyle)))
		(command "-DIMSTYLE" "restore" dimstylename)
		(setvar "DIMTMOVE" 1)
		(setvar "DIMTFILL" 1)
		(command "-DIMSTYLE" "save" dimstylename "Y")
	)
	(setvar "CMDECHO" oldcmdecho)
(princ)
)

;;--------------------------------------------;;
;;--------------------------------------------;;

(princ)

;;--------------------------------------------;;
;;--------------------------------------------;;

 

  • Like 1

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