Author Topic: dimension reactor revisited...again  (Read 3414 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
dimension reactor revisited...again
« on: January 12, 2004, 10:45:15 AM »
hey guys i need some help figuring out how to fix some problems with this reactor. there's a few things causing some problems. when i dimension using my scale to 4 style it sets the dim scale as 1. also sometimes the color doesn't switch to red and it sets the colors of various elements to colors other than red which i have set in my dimstyles. does anyone know why these problems are occuring? if so could you please help me out. thanks alot

dan





Code: [Select]
(vl-load-com)
(vl-load-reactors)
(defun ax:MakeLayer (lName / oLayer)
  (if
    (vl-catch-all-error-p
      (setq oLayer
          (vl-catch-all-apply
            'vla-add
              (list
                (vla-get-layers
                  (vla-get-activedocument
                    (vlax-get-acad-object)
                    )
                  )
                lName
                )
             )
          )
        )
    nil
    oLayer
    )
  )
(vlr-command-reactor
  nil
  '((:vlr-CommandWillStart . StartCommand))
  )
(vlr-command-reactor
  nil
  '((:vlr-commandEnded . EndCommand))
  )
(vlr-command-reactor
  nil
  '((:vlr-commandCancelled . EndCommand))
  )
(defun StartCommand (calling-reactor startcommandinfo / thecommandstart)
  (setq thecommandstart (nth 0 startcommandInfo))
  (cond
    ((= thecommandstart "DIMLINEAR")
     ; If the dimlinear command is called then
      (match:layer)
      ; go do the Match:layer function
     )
    ((= thecommandstart "DIMALIGNED")
      (match:layer)
     )
    ((= thecommandstart "QDIM")
      (match:layer)
     )
    ((= thecommandstart "DIMBASELINE")
      (match:layer)
     )
    ((= thecommandstart "QLEADER")
      (match:layer)
     )
    ((= thecommandstart "DIMCONTINUE")
      (match:layer)
     )
    ((= thecommandstart "DIMANGULAR")
      (match:layer)
     )
    ((= thecommandstart "DIMRADIUS")
      (match:layer)
     )
    ((= thecommandstart "DIMDIAMETER")
      (match:layer)
     )
    ((= thecommandstart "DIMORDINATE")
      (match:layer)
     )
    )
  )
(defun EndCommand (calling-reactor endcommandInfo / thecommandend)
  (setq thecommandend (nth 0 endcommandInfo))
  (cond
    ((= thecommandend "DIMLINEAR")
     ; If the dimlinear command has ended then
      (EC:MatchLayer)
      ; go do the EC:MatchLayer function
     )
    ((= thecommandend "DIMALIGNED")
      (EC:MatchLayer)
     )
    ((= thecommandend "QDIM")
      (EC:MatchLayer)
     )
    ((= thecommandend "DIMBASELINE")
      (EC:MatchLayer)
     )
    )
  )
(defun match:layer (/ LayerName ex:dimstyle)
  (setq ex:layer (getvar 'clayer))
  (setq ex:dimstyle (getvar 'dimstyle))
  (if (/= ex:layer ex:dimstyle)
    (progn
      (setq LayerName (ax:MakeLayer ex:dimstyle))
      (vla-put-ActiveLayer
        (vla-get-activedocument
          (vlax-get-acad-object)
          )
        LayerName
        )
      (if (not (vlax-object-released-p LayerName))
        (vlax-release-object LayerName)
        )
      (princ)
      )
    )
  )
(defun EC:MatchLayer (/ LayerName)
  (progn
    (setq LayerName (ax:MakeLayer ex:layer))
    (vla-put-ActiveLayer
      (vla-get-activedocument
        (vlax-get-acad-object)
        )
      LayerName
      )
    (if
      (not
        (vlax-object-released-p LayerName)
        )
      (vlax-release-object LayerName)
      )
    (setq ex:layer nil)
    (princ)
    )
  )

Columbia

  • Guest
dimension reactor revisited...again
« Reply #1 on: January 13, 2004, 12:48:39 PM »
I'm not exactly sure what you are asking...

From what I can tell of this reactor, all it's doing is setting a layer active if a dimension or leader command is called.  As such this reactor should not be affecting any color of anything.  So there lies my confusion.  If you could post a little bit more of a specific description, then please do so...

In the meantime, I have posted with this an alternative method of writing portions of your code, as well as some tips that I have run across.  I hope you don't mind...   :)

Code: [Select]

(vl-load-com)
(vl-load-reactors)
(defun ax:MakeLayer (lName / oLayer)
  (if
    (vl-catch-all-error-p
      (setq oLayer
          (vl-catch-all-apply
            'vla-add
              (list
                (vla-get-layers
                  (vla-get-activedocument
                    (vlax-get-acad-object)
                    )
                  )
                lName
                )
             )
          )
        )
    nil
    oLayer
    )
  )
; set a variable to the reactor object so that you can release it later if you want to
(setq $$LayerReactor$$
  (vlr-command-reactor nil
   '(
      (:vlr-CommandWillStart . StartCommand)
      (:vlr-commandEnded . EndCommand)
      (:vlr-commandCancelled . EndCommand)
      (:vlr-commandFailed . EndCommand)
    )
  )
)

(defun StartCommand (calling-reactor startcommandinfo / thecommandstart)
  (setq thecommandstart (nth 0 startcommandInfo))
  (if
    (not
      (member
        (car thecommandstart)
        ;; a list of commands that are known to cause problems
        ;; if a reactor process is tied to them...
         (list "U" "UNDO" "EXIT" "END" "CLOSE" "OPEN" "REDO" "QSAVE"  "SAVEAS")
      )
    )
    (cond
      ( (wcmatch thecommandstart "*DIM*") ;; any DIM command
        (match:layer)
        ; go do the Match:layer function
      )
      ( (wcmatch thecommandstart "*LEADER*") ;; any LEADER command
        (match:layer)
      )
    );cond
  );if
);defun

;; you don't need to look to see what command ended just go ahead
;; reset the layer if it the name exists in the variable you set
;; up earlier.
(defun EndCommand (calling-reactor endcommandInfo / thecommandend)
  (if
    (not
      (member
        (car callback)
        (list "U" "UNDO" "EXIT" "END" "CLOSE" "OPEN" "REDO" "QSAVE" "SAVEAS")
      )
    )
    (if ex:layer (EC:MatchLayer))
  )
)

(defun match:layer (/ LayerName ex:dimstyle)
  (setq ex:layer (getvar 'clayer))
  (setq ex:dimstyle (getvar 'dimstyle))
  (if (/= ex:layer ex:dimstyle)
    (progn
      (setq LayerName (ax:MakeLayer ex:dimstyle))
      (vla-put-ActiveLayer
        (vla-get-activedocument
          (vlax-get-acad-object)
          )
        LayerName
        )
      (if (not (vlax-object-released-p LayerName))
        (vlax-release-object LayerName)
        )
      (princ)
      )
    )
  )

(defun EC:MatchLayer (/ LayerName)
  (progn
    (setq LayerName (ax:MakeLayer ex:layer))
    (vla-put-ActiveLayer
      (vla-get-activedocument
        (vlax-get-acad-object)
        )
      LayerName
      )
    (if
      (not
        (vlax-object-released-p LayerName)
        )
      (vlax-release-object LayerName)
      )
    (setq ex:layer nil)
    (princ)
    )
  )

ELOQUINTET

  • Guest
dimension reactor revisited...again
« Reply #2 on: January 13, 2004, 02:30:09 PM »
hey columbia thanks for the response. after a little bit of exploring i think i've found my problem. i have a style called aval 04. this is what i was looking at and the scale was set to 4 and the color bylayer (red). what i didn't look at was the substyle which is aval04-linear. this is where the problem was hiding. the scale dimensions to layout buttons was on and the text color was set to green. so everything is back in order now. by the way, where are you from in virginia. i am originally from virginia beach. just curious. thanks