Jump to content

Recommended Posts

Posted (edited)

Hello, I'm trying to write a code that changes the dimension style of all dimensions in layer Dimension(ISO). I need the code to change it to variable "DimStyleOverrider" and this variable must be dependant on another variable. When OldFactor = 10 I need "DimStyleOverrider" to be "Change10" and when OldFactor = 5 I need it to be "Change5". You can assume these styles already exist in the file. I hope someone can help me.

Edited by ElAmigo
Posted

I have been able to solve it :)

Posted
On 3/8/2024 at 9:17 AM, ElAmigo said:

I have been able to solve it :)

@ElAmigo it would be nice if you could share your solution, so we can learn about it. 

Posted
(defun WhichDimension ()
  (setq DimStyleOverrider
    (cond
      ((= OldFactor 5) "Change5")
      ((= OldFactor 10) "Change10")

(defun example () 
	(WhichDimension)
	(while (< i (sslength selectie))
   	 (setq ent (ssname selectie i)) ; 
   	 (setq data (entget ent))
   	 (if (= (cdr (assoc 0 data)) "DIMENSION") ; 
   	   (progn
        (setq newData (subst (cons 3 DimStyleOverrider) (assoc 3 data) data)) ; Changes DIMSTYLE
        (entmod newData)
        (entupd ent)
      )
    )
    (setq i (+ i 1))
  )
 )
             

I hope this is clear enough. Had to change some names. This code works for me but after changing the DIMSTYLE it doesn't update everything that should. I created another post about that because I haven't been able to find a solution in days.

  • Like 1
Posted
1 minute ago, ElAmigo said:
(defun WhichDimension ()
  (setq DimStyleOverrider
    (cond
      ((= OldFactor 5) "Change5")
      ((= OldFactor 10) "Change10")

(defun example () 
	(WhichDimension)
	(while (< i (sslength selectie))
   	 (setq ent (ssname selectie i)) ; 
   	 (setq data (entget ent))
   	 (if (= (cdr (assoc 0 data)) "DIMENSION") ; 
   	   (progn
        (setq newData (subst (cons 3 DimStyleOverrider) (assoc 3 data) data)) ; Changes DIMSTYLE
        (entmod newData)
        (entupd ent)
      )
    )
    (setq i (+ i 1))
  )
 )
             

I hope this is clear enough. Had to change some names. This code works for me but after changing the DIMSTYLE it doesn't update everything that should. I created another post about that because I haven't been able to find a solution in days.

@ElAmigo Thanks 

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