Code Red > AutoLISP (Vanilla / Visual)

dimscale in dxf code?

(1/2) > >>

paulmcz:
I'd like to select dimension and set the dimscale to the value that dimension has. Where in the dxf code can I find the value and how can I retrieve it, if the dimscale for that dimension was set to 1?
This is what I have but it doesn't work if the selected dimension has dimscale 1.


--- Code: ---(defun c:dsc (/ dim lst xd)
(setq dim (car (entsel "\n Select dimension to copy dimscale from: ")))
(setq lst (entget dim '("ACAD")))
(setq xd (cdr (assoc 1040 (cdadr (assoc -3 lst)))))
(setvar "dimscale" xd)
)
--- End code ---

Thanks,
Paul.

Crank:

--- Code: ---(command ".dim1" "restore" "" pause)
--- End code ---

Jeff_M:

--- Code: ---(or (setq xd (cdr (assoc 1040 (cdadr (assoc -3 lst)))))
    (setq xd 1.0)
    )

--- End code ---
This will default to 1 if the selected dimension has not been altered.

A comment if I may: You should verify that 1.) the user DID select something, and 2.) the selected entity IS a dimension.....

paulmcz:

--- Quote from: Jeff_M on June 27, 2006, 05:42:35 PM ---
--- Code: ---(or (setq xd (cdr (assoc 1040 (cdadr (assoc -3 lst)))))
    (setq xd 1.0)
    )

--- End code ---
This will default to 1 if the selected dimension has not been altered.

A comment if I may: You should verify that 1.) the user DID select something, and 2.) the selected entity IS a dimension.....

--- End quote ---

Thanks Jeff. That's what I have.


--- Code: ---(defun c:dsc (/ dim lst xd)
  (command "cmdecho" (getvar "cmdecho"))
  (setq
    dim (car (entsel "\n Select dimension to copy dimscale from: "))
  )
  (setq lst (entget dim '("ACAD")))
  (cond ((or
   (= (cdr (assoc 0 lst)) "DIMENSION")
   (= (cdr (assoc 0 lst)) "LEADER")
)
(if (assoc -3 lst)
    (setq xd (cdr (assoc 1040 (cdadr (assoc -3 lst)))))
    (setq xd 1.0)
  )
   (setvar "dimscale" xd)
   (princ (strcat "\n Dimscale is now set to: " (rtos xd 2 3)))

)
(T (princ "\n No dimension selected"))
  )
  (princ)
)
--- End code ---

I am wondering if the dimscale value exists in the code if you select dimension that has dimscale 1. This > (assoc -3 lst) < evaluates to nil in such case.

paulmcz:

--- Quote from: Crank on June 27, 2006, 05:27:18 PM ---
--- Code: ---(command ".dim1" "restore" "" pause)
--- End code ---

--- End quote ---

Very simple and it does the job too.
Thanks.

Navigation

[0] Message Index

[#] Next page

Go to full version