|
Welcome, Guest.
|
||||||
| AutoLISP AutoLISP or Visual LISP, learn both here! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: 2003-04
Location: Stafford, UK
Posts: 34
![]() |
I am looking for a routine to set the dimscale variable by selecting an existing dimension.
Is this possible? Many thanks ..::KIEREN::.. |
|
|
|
|
|
#2 | |
|
I could stop if I wanted to
Join Date: 2002-02
Location: Galloway, Oh
Posts: 227
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Give this a try:
Code:
;;-INFO-
;; Description: MKSxMDimCur makes the dimstyle of the selected object current.
;; Alias: md
;; Created by: Michael K. Sretenovic`
;;Requested by: Michael K. Sretenovic`
;;Date created: 06-24-2004
;;Modification Notes:
;;
;;-INFO-
(defun c:MKSxMDimCur
(
/
dCol ;;variable - dimstyle collection
dList ;;variable - list of supported dimension objects
dObj ;;variable - dimension object
doc ;;variable - current active drawing
dType ;;variable - style name of dimension
obj ;;variable - object to check
*Error* ;;function - standard error handler
)
;;*Error* - standard error handler: (*Error* msg)
(defun *Error*(msg / flag)
(vla-endUndoMark doc)
(cond
((not msg))
((member (strcase msg t) '("console break" "function cancelled" "quit / exit abort"))(setq flag t))
((princ (strcat "\nError: " msg)) (setq flag t))
)
(if flag (vl-cmdf "._u"))
(princ)
)
;;Main - main portion of routine
(setq doc (vla-get-activeDocument (vlax-get-acad-object))
dCol (vla-get-dimStyles doc) ;get dimstyle collection
dList (list
"AcDbRotatedDimension"
"AcDbAlignedDimension"
"AcDbLeader"
"AcDb2LineAngularDimension"
"AcDbRadialDimension"
"AcDbDiametricDimension"
) ;create list of dim objects
)
(vla-startUndoMark doc) ;set undo mark
(princ "\n\nSelect dimension to make current: ")
(while (not obj)
(if (not (member (vla-get-objectName (setq obj (vlax-ename->vla-object (ssname (ssget ":S") 0)))) dList))
(setq obj nil) ;if not in list, set to nil
)
)
(setq dType (vla-get-styleName obj))
(vlax-for dObj dCol ;loop to find dimstyle in dimstyle collection
(if (= (vla-get-name dObj) dType)
(setq dType dObj)
)
)
(vla-put-activeDimStyle doc dType) ;set dimstyle current
(*Error* nil)
)
__________________
Michael K. Sretenović Quote:
|
|
|
|
|
|
|
#3 |
|
I could stop if I wanted to
Join Date: 2003-05
Posts: 335
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
kieren,
Here is a little something I cooked up. Hope you like it. This was tested in A2K, but should work in newer versions as well. Code:
(defun c:dc (/ ss dim echo) (princ "\nSelect a Dimension to make current: ") (while (not ss) (setq ss (ssget '((0 . "DIMENSION")))) (if ss (if (> (sslength ss) 1) (and (princ "\nToo many Dimensions selected. Please select only one. " ) (setq ss nil) ) ) (princ "\nNothing selected. Please try again. ") ) ) (setq echo (getvar "cmdecho")) (if (eq echo 1) (setvar "cmdecho" 0) ) (setq dim (cdr (assoc 3 (entget (ssname ss 0))))) (command "-DIMSTYLE" "restore" dim) (setvar "cmdecho" echo) (princ (strcat "\nDimstyle has been changed to " dim)) (princ) )
__________________
Good Blockin' Will DeLoach AutoCad / ADT 2006 |
|
|
|
|
|
#4 |
|
Member
Join Date: 2003-04
Location: Stafford, UK
Posts: 34
![]() |
Thanks guys, but not quite what I meant! (though those routines will prove v useful!)
I would like to get the dimscale value of an existing dimension and then update my global variable (dimscale) to that value. ie. (see if this makes any sense!): dimscale value in an existing drawing is 1. An existing dimension in that drawing has been created with a dimscale value of 25. I would like to extract that value of 25 and set my global "dimscale" variable to that value. I have routines that insert blocks to the variable "dimscale", so by selecting an existing dimension, I can insert the blocks at that chosen scale, without having to manually check and adjust the dimscale variable. Hope thats a bit clearer?! Many thanks, ..::KIEREN::.. |
|
|
|
|
|
#5 |
|
I could stop if I wanted to
Join Date: 2003-05
Posts: 335
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Kieren,
That's exactly what it does. Can you elaborate any more clearly on what your trying to do.
__________________
Good Blockin' Will DeLoach AutoCad / ADT 2006 |
|
|
|
|
|
#6 |
|
Member
Join Date: 2003-04
Location: Stafford, UK
Posts: 34
![]() |
I'll try Will!
From what I can see (and tried!), you code sets the dimstyle to another selected existing dimension? I am just trying to extract the "dimscale" variable, not all the "dimstyle" settings. If an existing dim on the drawing has been drawn with variable "dimscale" set to 25, then I want to be able to automate the following command line sequence based on that variable: ---------------------------- Command: dimscale Enter new value for DIMSCALE <1.0000>: 25 ----------------------------- Hope that's clearer? That's all I'm trying to do!!!! ..::KIEREN::.. |
|
|
|
|
|
#7 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
This will override DIMSCALE with a value depending on:
1. If chosen dimension has overriden DIMSCALE then use this 2. Otherwise, use DIMSCALE of chosen dimensions dimension style Is that what you're looking for? Code:
(defun C:SetDS (/ ent entl dscale dstyle)
(cond
((and (setq ent (entsel "\nSelect dimension object: "))
(= (cdr (assoc 0 (setq entl (entget (car ent) '("ACAD")))))
"DIMENSION"
)
)
(cond ((setq dscale (cdr (assoc 1040 (cdadr (assoc -3 entl))))))
((setq dstyle (tblsearch "DIMSTYLE" (cdr (assoc 3 entl))))
(setq dscale (cdr (assoc 40 dstyle)))
)
)
)
)
(and dscale (setvar "DIMSCALE" dscale))
)
|
|
|
|
|
|
#8 |
|
Member
Join Date: 2003-04
Location: Stafford, UK
Posts: 34
![]() |
Perfect!!
Thanks Stig, much appreciated. ..::KIEREN::.. |
|
|
|
|
|
#9 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
You're welcome
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Default Printer Setting | studio3p | Revit Architecture - General | 15 | 2007-06-12 04:56 PM |
| Setting up a Sheet Set | RobertB | AutoCAD Sheet Set Manager | 4 | 2005-09-16 07:08 AM |
| Dimension layer setting | stanmccall | AutoCAD Customization | 4 | 2004-06-21 09:15 PM |
| Setting the Current Plot Configuration Programatically | Marshal_Rosenberg | VBA | 2 | 2004-06-18 05:56 AM |
| Plot to file setting toggles off by itself | CBLENDERMANN | AutoCAD Plotting | 6 | 2004-06-03 07:38 PM |