Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

How to get the dim scale with lisp

Wheelie22
Collaborator

How to get the dim scale with lisp

Wheelie22
Collaborator
Collaborator

I use this list :

((1000 . "DSTYLE") (1002 . "{") (1070 . 144) (1040 . -2.0) (1070 . 40) (1040 . 1.0) (1002 . "}"))

some times the first 1040 is the actual scale, but some times its the second

((1000 . "DSTYLE") (1002 . "{") (1070 . 144) (1040 . 5.0) (1070 . 40) (1040 . 1.0) (1070 . 43) (1040 . 5.0) (1002 . "}"))

some times it is in there 3 times ? Smiley Surprised

 

but the CRTL-1 window has the right 1

 

dim scale.png

How do i know where the scale is ?

 

 

0 Likes
Reply
Accepted solutions (1)
1,692 Views
4 Replies
Replies (4)

Kent1Cooper
Consultant
Consultant

I believe it's the 1040 entry that immediately follows  (1070 . 144).

Kent Cooper, AIA

ambrosl
Autodesk
Autodesk
Accepted solution

I believe Kent is correct, but you might be able to eliminate the guess work though if you use the following AutoLISP functions which allow you to move away from needing to dig through the DXF code groups:

 

  • getpropertyvalue
  • setpropertyvalue
  • dumpallproperties

The above functions take Dimension Overrides into consideration and will return that value rather than the base dimension style when they are applied.

 

DUMPALLPROPERTIES returns a list of the properties that apply to a specific entity.

 

Begin dumping object (class: AcDbRotatedDimension)
...
Dimgap (type: double)  (LocalName: Text offset) = 0.090000
Dimjust (type: DimHorizontalTextPosEnum)  (LocalName: Text pos hor) = 0
Dimldrblk (type: AcDbObjectId) = 0
Dimlfac (type: double)  (LocalName: Dim scale linear) = 1.000000
Dimlim (type: bool) = 0
Dimltex1 (type: AcDbObjectId)  (LocalName: Ext line 1 linetype) = 2a235140
Dimltex2 (type: AcDbObjectId)  (LocalName: Ext line 2 linetype) = 2a235140
Dimltype (type: AcDbObjectId)  (LocalName: Dim line linetype) = 2a235140
...
End object dump

When you have the property name and the entity, you can then get or set the property value.

 

(setq ent (car (entsel)))
(getpropertyvalue ent "Dimlfac")

Using the GETPROPERTYVALUE and SETPROPERTYVALUE functions are much easier than sifting through DXF code values, habits are hard to break even I gravitate to DXF codes yet, and using those functions does require less code in the end.  The functions were introduced back in AutoCAD 2011, so they have been around for a while unless you need to support AutoCAD 2010 or earlier then you would need to continue using the DXF code values directly.

 

Best of luck finishing your code.



Lee Ambrosius
Senior Principal Content Experience Designer
For additional help, check out the AutoCAD Developer Documentation

JBerns
Advisor
Advisor

@Kent1Cooper (Kent) / @ambrosl (Lee),

 

I know this is an old post, but I did not find anything more current on this topic.

 

Lee mentioned that the get/set property functions make it easier to work with dimensions.

 

My goal is to:

  • capture a dimension's overrides (e.g. precision, tolerance, etc.)
  • apply a different dimstyle (DIMSCALE)
  • then reapply the captured overrides

I prefer to avoid the use of the 'command' functions. FYI - we do not use paperspace (various reasons).

 

I have not been able to determine when a dimension has overrides when using properties. When using DXF group codes, the overrides are listed in the Extended Data. Is the override info identifiable using properties?

 

I have concluded that DXF codes will need to be used to preserve the overrides after applying a different dimstyle?

 

If it can be done with properties, I would welcome any info to perform the process mentioned above. Perhaps a combination of property and DXF codes.

 

Thank you for your time and attention. I look forward to your reply.

 

 

Regards,

Jerry

 

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes

JBerns
Advisor
Advisor

Since we only change a few dimension properties, I came up with this solution to capture overrides, set dimstyle, and then reapply overrides. Not the prettiest looking code, but it works.

 

  ;; loop through selection set
  (setq COUNT -1)
  (while (< (setq COUNT (1+ COUNT)) (sslength ssDims))

    ;; get the entity and object info
    (if	(setq ENT (ssname ssDims COUNT))
      (setq obj (vlax-ename->vla-object ENT))
    ) ;_if

    ;; capture dimension properties
    (setq d01	(vla-get-PrimaryUnitsPrecision obj)	;;; DIMDEC
          d02	(vla-get-TextGap obj)				;;; DIMGAP
          d03	(vla-get-LinearScaleFactor obj)		;;; DIMLFAC
          d04	(getpropertyvalue ENT "Dimlim")		;;; DIMLIM
          d05	(vla-get-UnitsFormat obj)			;;; DIMLUNIT
          d06	(vla-get-RoundDistance obj)			;;; DIMRND
          d07	(vla-get-TolerancePrecision obj)	;;; DIMTDEC
          d08	(vla-get-ToleranceLowerLimit obj)	;;; DIMTM
          d09	(vla-get-TextOutsideAlign obj)		;;; DIMTOH
          d10	(vla-get-ToleranceDisplay obj)		;;; DIMTOL
          d11	(vla-get-ToleranceUpperLimit obj)	;;; DIMTP
    ) ;_setq

    ;; get the dimstyle property
    (setq tmp1 (vla-get-StyleName obj))

    ;; set the dimension property
    (cond
      ((wcmatch (strcase tmp1) "*ARROW*")	(vla-put-stylename obj (nth 1 NewDimStyle)))
      (T 									(vla-put-stylename obj (nth 0 NewDimStyle)))
    ) ;_cond

    ;; reapply overrides
    (vla-put-PrimaryUnitsPrecision obj d01)		;;; DIMDEC
    (vla-put-TextGap obj d02)					;;; DIMGAP
    (vla-put-LinearScaleFactor obj d03)			;;; DIMLFAC
    (setpropertyvalue ENT "Dimlim" d04)			;;; DIMLIM
    (vla-put-UnitsFormat obj d05)				;;; DIMLUNIT
    (vla-put-RoundDistance obj d06)				;;; DIMRND
    (vla-put-TolerancePrecision obj d07)		;;; DIMTDEC
    (vla-put-ToleranceLowerLimit obj d08)		;;; DIMTM
    (vla-put-TextOutsideAlign obj d09)			;;; DIMTOH
    (vla-put-ToleranceDisplay obj d10)			;;; DIMTOL
    (vla-put-ToleranceUpperLimit obj d11)		;;; DIMTP

  ) ;_while

 

Couldn't find a method or property for DIMLIM, so resorted to using [get/set]propertyvalue functions.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes