Saturday, November 21, 2009
Home   |   Search   |   About AUGI   |   My AUGI   |   Join Now

Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP
 Welcome, Guest. 

Login

Join Now FAQ Members List Calendar Search Today's Posts Mark Forums Read

AutoLISP AutoLISP or Visual LISP, learn both here!

Reply
 
Thread Tools Display Modes
Old 2004-06-24, 10:34 AM   #1
kieren
Member
 
kieren's Avatar
 
Join Date: 2003-04
Location: Stafford, UK
Posts: 34
kieren is starting their journey
Default Setting dimscale

I am looking for a routine to set the dimscale variable by selecting an existing dimension.
Is this possible?

Many thanks

..::KIEREN::..
kieren is offline   Reply With Quote
Old 2004-06-24, 03:44 PM   #2
msretenovic
I could stop if I wanted to
 
msretenovic's Avatar
 
Join Date: 2002-02
Location: Galloway, Oh
Posts: 227
msretenovic is a beam of lightmsretenovic is a beam of lightmsretenovic is a beam of lightmsretenovic is a beam of lightmsretenovic is a beam of lightmsretenovic is a beam of lightmsretenovic is a beam of lightmsretenovic is a beam of lightmsretenovic is a beam of lightmsretenovic is a beam of lightmsretenovic is a beam of light
Lightbulb RE: Setting dimscale

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:
Most folks are about as happy as they make up their minds to be.
-Abraham Lincoln (1809-1865)
-16th president of The United States of America (1861 - 1865)
msretenovic is offline   Reply With Quote
Old 2004-06-24, 03:46 PM   #3
whdjr
I could stop if I wanted to
 
Join Date: 2003-05
Posts: 335
whdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of light
Default RE: Setting dimscale

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
whdjr is offline   Reply With Quote
Old 2004-06-24, 05:28 PM   #4
kieren
Member
 
kieren's Avatar
 
Join Date: 2003-04
Location: Stafford, UK
Posts: 34
kieren is starting their journey
Lightbulb RE: Setting dimscale

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::..
kieren is offline   Reply With Quote
Old 2004-06-24, 06:12 PM   #5
whdjr
I could stop if I wanted to
 
Join Date: 2003-05
Posts: 335
whdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of lightwhdjr is a beam of light
Default RE: Setting dimscale

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
whdjr is offline   Reply With Quote
Old 2004-06-24, 06:27 PM   #6
kieren
Member
 
kieren's Avatar
 
Join Date: 2003-04
Location: Stafford, UK
Posts: 34
kieren is starting their journey
Unhappy RE: Setting dimscale

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::..
kieren is offline   Reply With Quote
Old 2004-06-24, 06:41 PM   #7
stig.madsen
100 Club
 
Join Date: 2000-12
Posts: 126
stig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightly
Default

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))
)
stig.madsen is offline   Reply With Quote
Old 2004-06-24, 06:44 PM   #8
kieren
Member
 
kieren's Avatar
 
Join Date: 2003-04
Location: Stafford, UK
Posts: 34
kieren is starting their journey
Thumbs up RE: Setting dimscale

Perfect!!

Thanks Stig, much appreciated.

..::KIEREN::..
kieren is offline   Reply With Quote
Old 2004-06-24, 06:48 PM   #9
stig.madsen
100 Club
 
Join Date: 2000-12
Posts: 126
stig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightlystig.madsen is glowing brightly
Default

You're welcome
stig.madsen is offline   Reply With Quote
Reply


Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

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


All times are GMT +1. The time now is 03:42 PM.