Match Dimension properties without changing dimension style

Match Dimension properties without changing dimension style

mujaffar_peerzade
Explorer Explorer
1,635 Views
15 Replies
Message 1 of 16

Match Dimension properties without changing dimension style

mujaffar_peerzade
Explorer
Explorer

Hello, 

 

Can someone share a custom command using which i can match properties of one dimension to another except for Dimension Style. I want to keep Dimension Style as it is and match only tolerance and text (manually entered into dimension) of another dimension.

 

or something using which when i change dimension style then dimension precisions and tolerance should remain intact.

 

THIS WILL HELP ME LOT. SO PLEASE HELP

 

Thanks,

Muzaffar

0 Likes
Accepted solutions (2)
1,636 Views
15 Replies
Replies (15)
Message 2 of 16

Sea-Haven
Mentor
Mentor

Would it not be easier to make the correct dimension style ? Then can choose or change at will.

 

That is what drawing templates are for do once. DWT.

0 Likes
Message 3 of 16

mujaffar_peerzade
Explorer
Explorer

actually i have received autocad files exported from solidworks software in which dimension style and layers are completely different. That is why im in need of this customisation.

 

thanks

muzaffar

0 Likes
Message 4 of 16

Moshe-A
Mentor
Mentor

@mujaffar_peerzade ,

 

post a sample drawing with a dimension text \ tolerance before and after.

 

Moshe

 

Message 5 of 16

mujaffar_peerzade
Explorer
Explorer

I HAVE ALREADY ATTACHED AN IMAGE AS REFERENCE.

0 Likes
Message 6 of 16

mujaffar_peerzade
Explorer
Explorer

AS SOON AS I APPLY NEW DIMSTYLE I LOSE TOLERANCE AND REQUIRED DIMENISON PRECISION.

 

CAN YOU PLEASE HELP. I HAVE THOUSANDS OF SUCH DRAWINGS .

0 Likes
Message 7 of 16

Moshe-A
Mentor
Mentor

@mujaffar_peerzade ,

 

the deal here, you ask for help and others voluntarily (in this case that would be me) asking you to help me to help you 😀,

so for the second time this is my request:

 

Post a sample drawing with before and after.

 

Message 8 of 16

mujaffar_peerzade
Explorer
Explorer

HERE IT IS...PFA

0 Likes
Message 9 of 16

Moshe-A
Mentor
Mentor

@mujaffar_peerzade ,

 

check this:

 

this of course has no power of MATCHPROP command, it only let you pick source object (a dimension) and than copies it's text override value to a destination object (a dimension).

 

note that in your sample drawing there are also notes that are blocks, mtxp does not handle them.

 

enjoy

Moshe

 

(vl-load-com)

; Match Text Property
(defun c:mtxp (/ validate-sel echo-msg ; local functions
	         flag pick ename0 ename1 AcDbDim0 AcDbDim1)

 (defun validate-sel (Qent) ; quoted argument
  (not
    (and
      (set Qent (car pick)) ; indirect set
      (eq (cdr (assoc '0 (entget (eval Qent)))) "DIMENSION")
    )
  )
 ); validate-sel

  
 (defun echo-msg ()
  (vlr-beep-reaction)
  (prompt "\nObject selected is not a dimension.")
 ); echo-msg


 ; here start c:mtxp
 (while (setq pick (entsel "\nPick source object: "))
   (cond
    ((validate-sel 'ename0) ; pass quote param
     (echo-msg)
    ); case
    ( t
     (setq flag nil)
     (setq AcDbDim0 (vlax-ename->vla-object ename0))

     (while (and
	      (not flag) 
	      (setq pick (entsel "\nPick destination object: "))
            )
      (cond
       ((validate-sel 'ename1) ; pass quote param
        (echo-msg)
       ); case
       ( t
        (setq AcDbDim1 (vlax-ename->vla-object ename1))
        (vla-put-textOverride AcDbDim1 (vla-get-textOverride AcDbDim0))
        (setq flag t)
	
        (vlax-release-object AcDbDim1)
       ); case
      ); cond

     ); while

     (vlax-release-object AcDbDim0) 
    ); case
   ); cond

 ); while

 (princ) 
); c:mtxp

 

Message 10 of 16

mujaffar_peerzade
Explorer
Explorer

thanks moshe for this code but its helping me to copy only text and not the tolerance. i need it mainly for copying tolerance with precision.

 

i really appreciate the quickness with which you are responding. thanks

 

0 Likes
Message 11 of 16

Moshe-A
Mentor
Mentor
Accepted solution

@mujaffar_peerzade ,

 

your are not clear, at first you said you want to copy text + tolerance

 

here is the fix

if the source object is a block,  it will take the text value and copy it to a dimension destination. destination always must be a dimension.

 

this fix copies all tolerance properties (not text override) but you should note that coping the precision will effect the text value.

 

Moshe

 

 

 

 

(vl-load-com)

; Match Text Property
(defun c:mtxp (/ validate-sel ; local function
	         flag pick ename0 ename1 AcDbDim0 AcDbDim1)

 (defun validate-sel (Qent sw / p nent)
  (set Qent (car pick))
   
  (cond
   ((= sw 0) ; coming from source
    (cond
     ((eq (cdr (assoc '0 (entget (eval Qent)))) "INSERT")
      (if (and
	    (setq p (nentselp (cadr pick)))
            (setq nent (car p))
	    (wcmatch (cdr (assoc '0 (entget nent))) "TEXT,MTEXT")
	  )     
       (progn
	(set Qent nent) ; Qent gets the ename of text
        nil ; this is good
       ); progn
       t    ; this is error
      ); if
     ); case
     ((eq (cdr (assoc '0 (entget (eval Qent)))) "DIMENSION")
      nil ; this is good
     ); case
     ( t ) ; this error
    ); cond
   ); case
   ((= sw 1) ; coming from destination
    (not (eq (cdr (assoc '0 (entget (eval Qent)))) "DIMENSION"))
   ); case
  ); cond
 ); validate-sel

  
 ; here start c:mtxp
 (while (setq pick (entsel "\nPick source object: "))
   (cond
    ((validate-sel 'ename0 0) ; pass quote param
     (vlr-beep-reaction)
     (prompt "\nSource object can be a dimension or insert.")
    ); case
    ( t
     (setq flag nil)
     (setq AcDbDim0 (vlax-ename->vla-object ename0))

     (while (and
	      (not flag) 
	      (setq pick (entsel "\nPick destination object: "))
            )
      (cond
       ((validate-sel 'ename1 1) ; pass quote param
        (vlr-beep-reaction)
        (princ "\nDestination object must be dimension.")
       ); case
       ( t
        (setq AcDbDim1 (vlax-ename->vla-object ename1))

	(cond
         ((wcmatch (vla-get-objectName AcDbDim0) "AcDbText,AcDbMText")
          (vla-put-textOverride AcDbDim1 (vla-get-textString AcDbDim0))
	 ); case
	 ( t
         ; (vla-put-textOverride AcDbDim1 (vla-get-textOverride AcDbDim0))

	  (vla-put-TolerancePrecision AcDbDim1 (vla-get-TolerancePrecision AcDbDim0))
	  (vla-put-tolerancedisplay AcDbDim1 (vla-get-tolerancedisplay AcDbDim0))
	  (vla-put-toleranceLowerLimit AcDbDim1 (vla-get-toleranceLowerLimit AcDbDim0))
	  (vla-put-ToleranceUpperLimit AcDbDim1 (vla-get-ToleranceUpperLimit AcDbDim0))
	  (vla-put-ToleranceSuppressLeadingZeros AcDbDim1 (vla-get-ToleranceSuppressLeadingZeros AcDbDim0))
	  (vla-put-ToleranceSuppressTrailingZeros AcDbDim1 (vla-get-ToleranceSuppressTrailingZeros AcDbDim0))
	  (vla-put-ToleranceSuppressZeroFeet AcDbDim1 (vla-get-ToleranceSuppressZeroFeet AcDbDim0))
	  (vla-put-ToleranceSuppressZeroInches AcDbDim1 (vla-get-ToleranceSuppressZeroInches AcDbDim0))
	  
          (vla-put-AltTolerancePrecision AcDbDim1 (vla-get-AltTolerancePrecision AcDbDim0))
          (vla-put-AltToleranceSuppressLeadingZeros AcDbDim1 (vla-get-AltToleranceSuppressLeadingZeros AcDbDim0))
          (vla-put-AltToleranceSuppressTrailingZeros AcDbDim1 (vla-get-AltToleranceSuppressTrailingZeros AcDbDim0))
          (vla-put-AltToleranceSuppressZeroFeet AcDbDim1 (vla-get-AltToleranceSuppressZeroFeet AcDbDim0))
          (vla-put-AltToleranceSuppressZeroInches AcDbDim1 (vla-get-AltToleranceSuppressZeroInches AcDbDim0))
	  (vla-put-PrimaryUnitsPrecision AcDbDim1 (vla-get-PrimaryUnitsPrecision AcDbDim0))
	 ); case
	); cond

        (setq flag t)
        (vlax-release-object AcDbDim1)
       ); case
      ); cond

     ); while

     (vlax-release-object AcDbDim0) 
    ); case
   ); cond

 ); while

 (princ) 
)

 

 

 

Message 12 of 16

mujaffar_peerzade
Explorer
Explorer

thanks, Moshe, it worked but this time it is only the Dimension tolerance that it is copying and not the text (FITS) that it is copying. But my major problem has been resolved with this code. I will type FIT manually. 

 

also, I think you misunderstood what I stated in my question. I always wanted to copy tolerance (Tol+Fit+Tol precision) along with text in a dimension (refer to attached image for understanding what I meat exactly) without copying source object dimstyle. Anyways this new code will ease my job and I'm ok with it.

 

thanks for putting so much effort in this brother. Highly appreciated.

0 Likes
Message 13 of 16

Moshe-A
Mentor
Mentor
Accepted solution

@mujaffar_peerzade ,

 

You said: i need it mainly for copying tolerance with precision.  does that means text + tolerance?!

 

Anyway have this current version, it copies the text (it is the dimension text override) + all tolerance properties

and  made  fine tuning, so it's a little shorter.

 

again at source object you can pick a block with text (or attribute) and it's copy the text value to destination dimension. the destination must be a dimension.

 

Moshe

 

 

(vl-load-com)

; Match Text Property
(defun c:mtxp (/ chksel ; local function
	         flag pick ename0 ename1 AcDbDim0 AcDbDim1)
  
 (defun chksel (Qent sw / p nent)
  (set Qent (car pick))
   
  (cond
   ((= sw 0) ; coming from source
    (cond
     ((eq (cdr (assoc '0 (entget (eval Qent)))) "INSERT")
      (if (and
	    (setq p (nentselp (cadr pick)))
            (setq nent (car p))
	    (wcmatch (cdr (assoc '0 (entget nent))) "TEXT,MTEXT")
	  )     
       (progn
	(set Qent nent) ; Qent gets the ename of text
        nil ; this is good
       ); progn
       t    ; this is error
      ); if
     ); case
     ((eq (cdr (assoc '0 (entget (eval Qent)))) "DIMENSION")
      nil ; this is good
     ); case
     ( t ) ; this error
    ); cond
   ); case
   ((= sw 1) ; coming from destination
    (not (eq (cdr (assoc '0 (entget (eval Qent)))) "DIMENSION"))
   ); case
  ); cond
 ); chksel

  
 ; here start c:mtxp
 (while (setq pick (entsel "\nPick source object: "))
  (cond
   ((chksel 'ename0 0) ; pass quote param
    (vlr-beep-reaction)
    (prompt "\nSource object can be a dimension or insert.")
   ); case
   ( t
    (setq flag nil)
    (setq AcDbDim0 (vlax-ename->vla-object ename0))

    (while (and
             (not flag) 
	     (setq pick (entsel "\nPick destination object: "))
           )
     (cond
      ((chksel 'ename1 1) ; pass quote param
       (vlr-beep-reaction)
       (princ "\nDestination object must be dimension.")
      ); case
      ( t
       (setq AcDbDim1 (vlax-ename->vla-object ename1))

       (cond
        ((wcmatch (vla-get-objectName AcDbDim0) "AcDbText,AcDbMText")
         (vla-put-textOverride AcDbDim1 (vla-get-textString AcDbDim0))
        ); case
	( t
	 (foreach prop (list 'textOverride 'TolerancePrecision 'tolerancedisplay 'toleranceLowerLimit
			     'ToleranceUpperLimit 'ToleranceSuppressLeadingZeros 'ToleranceSuppressTrailingZeros
			     'ToleranceSuppressZeroFeet 'ToleranceSuppressZeroInches 'AltTolerancePrecision
			     'AltToleranceSuppressLeadingZeros 'AltToleranceSuppressTrailingZeros 'AltToleranceSuppressZeroFeet
			     'AltToleranceSuppressZeroInches 'PrimaryUnitsPrecision)
	  (vlax-put-property AcDbDim1 prop (vlax-get-property AcDbDim0 prop))
	 ); foreach
	); case
       ); cond

       (setq flag t)
       (vlax-release-object AcDbDim1)
      ); case
     ); cond

    ); while

    (vlax-release-object AcDbDim0) 
   ); case
  ); cond

 ); while

 (princ) 
); c:mtxp

 

 

 

 

Message 14 of 16

Sea-Haven
Mentor
Mentor

Moshe-A would Lee-mac's Steal.lsp be a good way to go pulling correct dimension style from another dwg then at least dim style is correct and the prefix could be read from another dim. 

0 Likes
Message 15 of 16

Moshe-A
Mentor
Mentor

@Sea-Haven ,

 


@Sea-Haven wrote:

Moshe-A would Lee-mac's Steal.lsp be a good way to go pulling correct dimension style from another dwg then at least dim style is correct and the prefix could be read from another dim. 


How this directly relate to @mujaffar_peerzade  request?

0 Likes
Message 16 of 16

Sea-Haven
Mentor
Mentor

As the tolerance is missing in the destination dimension changing dimstyle with tolerance set may help. This would mean you do not have to set all the "Tolerance.... variables. Rather set by the style. 

 

SeaHaven_0-1667778125629.png

 

0 Likes