ChangeDimScale command

Hi all.
I often change dimension style settings > Fight > Overall scale.

(my environment is Japanese so the translation may be a little different)

I am currently using a macro, C^C^_changedimscale registered.

However, with this macro, I always need to enter Y.

This is very annoying for me.

So I tried writing the following Lisp, but it does not work well.

----------------------------------------------------------

(defun c:CDS (/ scale)

  (setq scale (getreal “\nEnter new dimension scale: ”)))

  (if scale    (command “. _changedimscale” scale ‘Y’)

  )

  (princ))

---------------------------------------------------------

The BricsCAD command line looked like this

---------------------------------------------------------

: CDSEnter new dimension scale: 5

: . _changedimscaleEnter new overall scale: 5

The overall scale for the current dimension style “ISO-25” has been changed to 5

.Enter new dimension scale: Y
Unable to recognize “Y” command

--------------------------------------------------------

If you run changdimsacale from the command line

--------------------------------------------------------

: CHANGEDIMSCALEEnter a new overall scale: 5

: _.DIMSTYLE

Current dimension style: ISO-25

Different scale support: No

Update current dimension: _.

DIMADEC 2              

DIMDEC 4              

DIMFRAC 2              

DIMTDEC 4              

Select dimension style or [? /AN]/Apply(A)/Store(S)/Status(ST)/Variable(V)/Recall(R)] <Recall(R)>: _Restore

Dimension style to call, or [? List with] <select dimension>: ISO-25

Current dimension style is ISO-25.DIMSTYLE: _.DIMSTYLE

Current dimension style: ISO-25 Different scale support: No

Update current dimension: No

DIMSCALE 5              

Update current dimension: DIMSCALE 5 /AN]/Apply(A)/Save(S)/Status(ST)/Variable(V)/Call(R)] <Call(R)>

: _SaveEnter a style name to save, or [? to list]: ISO-25

The name is already in use.

Do you want to redefine it? [Yes (Y)/No (N)] <No (N)>:

The overall scale of the current dimension style “ISO-25” has been changed to 5.

The name is already in use. Do you want to redefine it? [Yes (Y)/No (N)] <No (N)>: y

-----------------------------------------------------------

Is there any better way to do this?
Best regards.

Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • Perhaps this will do what you want?

    ; Show and change the ScaleFactor of any dimensions and leaders in the selection set
    ; In the Properties panel, Scale Factor is called "Dim scale overall"
    (DEFUN c:SF (/ n ss1 ent1 obj1 oldSF newSF)
    (SETQ ss1 (ssget '((-4 . "<OR")(0 . "DIMENSION")(0 . "LEADER")(-4 . "OR>"))))
    (initget 6)
    (setq ent1 (ssname ss1 0))
    (setq obj1 (vlax-ename->vla-object ent1))
    (setq oldSF (rtos (vlax-get-property obj1 "ScaleFactor") 2))
    (SETQ newSF (GETREAL (STRCAT "\nEnter ScaleFactor <" oldSF ">: ")))
    (IF ss1 (REPEAT (SETQ n (SSLENGTH ss1))
    (VLA-PUT-SCALEFACTOR (VLAX-ENAME->VLA-OBJECT (SSNAME ss1 (SETQ n (1- n)))) newSF) ) )
    (if ss1 (sssetfirst nil ss1))
    (princ)
    )

  • Thank you very much for your great sample.
    However, while this method works for changing the object properties I have already written, it does not change the value of Overall Scale.

    I would like to either run the ChangeDimScale command without the “N” input or simply change the value of Drawing Explorer > Dimension Styles > Overall Scale.

  • Not sure about the command 'ChangeDimScale'. This is not available in the English version. But I think you should achieve your end result with this

    (defun c:CDS (/ scale)
    (setq scale (getreal "\nEnter new dimension scale: "))
    (if scale (command "dimscale" scale "-dimstyle" "s" (getvar 'dimstyle)))
    (princ)
    )

    When you change Dimscale in BricsCAD, the change is only applied to the overrides. But given that you are trying to change the parent dimstyle the above code should help.

  • @VGonsalves

    Thank you for your answer.

    guess BicsCAD may differ depending on the language version.

    Unfortunately, the Lisp you provided required a “Y” at the end.

    The following is the result of running the Lisp.
    ————————————————————-
    : CDS

    新しい寸法スケールを入力してください: 5

    : dimscaleDIMSCALE の新しい値(0 またはそれ以上) <3>: 5

    : -dimstyleカレントの寸法スタイル: JIS_M   異尺度対応: いいえ

    カレントの寸法を更新:

    DIMSCALE    5              

    寸法スタイル、または [?/異尺度対応 (AN)/適用 (A)/保存 (S)/ステータス (ST)/変数 (V)/呼出 (R)] <呼出 (R)>: s

    保存するスタイル名を入力、または [? で一覧表示]: JIS_M

    その名前は既に使用されています。再定義しますか? [はい (Y)/いいえ (N)] <いいえ (N)>:

    その名前は既に使用されています。再定義しますか? [はい (Y)/いいえ (N)] <いいえ (N)>: y

    寸法スタイル JIS_M が更新されました。

  • prefixing a command with an underscore should get you the global command context, I.e. command “_LINE”. This is so lisp functions are compatible regardless of language.

  • edited March 9

    Maybe this

     (setvar 'dimscale (getreal "\nEnter new dimension scale: "))

    Just a ps when you post sometimes the dbl quotes are changed to a left and right version so code does not work I just had it happen.

  • @ALANH

    Thank you very much.

    In my environment, the DIMSCALE variable changes, but the Drawing Explorer > Dimension Styles > Overall Scale value does not change.
    How about in your environment?

  • I don’t know how to change this via Lisp, but with python you can modify the dimension style directly. Additionally, overrides are stored in XDATA,

    import traceback
    from pyrx import Rx, Ge, Gi, Db, Ap, Ed
    
    
    # change dimscale in the dimstyle
    @Ap.Command("changeit")
    def justDoit():
        db = Db.curDb()
        dimStyle = Db.DimStyleTableRecord(db.dimstyle(), Db.OpenMode.kForWrite)
        old = dimStyle.dimscale()
        dimStyle.setDimscale(2.0)
        print(dimStyle.getName(), old, dimStyle.dimscale())
    
    
    # new dim use and override, get the value from XDATA
    @Ap.Command("checkit")
    def justCheckit():
        try:
            ps, id, _ = Ed.Editor.entSel("\nSelect:", Db.Dimension.desc())
            if ps != Ed.PromptStatus.eOk:
                return
            dim = Db.Dimension(id)
            print(dim.xData("ACAD"))
            # dimscale override is (1040, 1.0)
            # [(1001, 'ACAD'), (1000, 'DSTYLE'), (1002, '{'), (1070, 40), (1040, 1.0), (1002, '}')]
        except Exception as err:
            traceback.print_exception(err)
    
    
    # modify the override for the dimension
    @Ap.Command("doupdate")
    def justDoUpdate():
        try:
            ps, id, _ = Ed.Editor.entSel("\nSelect:", Db.Dimension.desc())
            if ps != Ed.PromptStatus.eOk:
                return
            
            #kForWrite
            dim = Db.Dimension(id, Db.OpenMode.kForWrite)
            
            # change dimscale override to (1040, 3.0)
            xd = [(1001, "ACAD"), (1000, "DSTYLE"), (1002, "{"), (1070, 40), (1040, 3.0), (1002, "}")]
            dim.setXData(xd)
        except Exception as err:
            traceback.print_exception(err)
    
    
    @Ap.Command("removerride")
    def justNukeIt():
        try:
            ps, id, _ = Ed.Editor.entSel("\nSelect:", Db.Dimension.desc())
            if ps != Ed.PromptStatus.eOk:
                return
            
            #kForWrite
            dim = Db.Dimension(id, Db.OpenMode.kForWrite)
            # remove dimscale override
            dim.setXData([(1001, "ACAD")])
        except Exception as err:
            traceback.print_exception(err)
    

  • So you want the change the dimscale in the style as a permanent thing.

    Maybe this

    (defun chdimsc (dname ht / doc)
    (vlax-for dim (vla-get-Dimstyles (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))
    (if (= (vlax-get dim 'name) dname)
    (progn
    (alert "in dim")
    (vla-put-activeDimstyle doc dim)
    (setvar "DIMSCALE" ht)
    (vla-copyfrom dim doc)
    )
    )
    )
    (princ)
    )
    (chdimsc "Standard" 2.0)

  • I am sorry for the delay in getting back to you, I could not take the time.
    Thank you for providing the valuable code.
    I have tried the code you provided.
    This code indeed changes the value of Overall Scale in Dimension Styles.
    However, unlike the ChangeDimScale command, this code does not change the Scale of the dimension already written.
    I still want to omit the “Y” in the ChangeDimScale command to indicate whether to update or not.

  • My Bricscad doesn't have a ChangeDimScale command, and I can't find one in online support or by a Google search. I think all the replies have made guesses about what such a command would do, but our guesses were all wrong. I can only make yet another blind guess:
    change the 'Y' in your c:CDS function to ""
    For some built-in commands used in Lisp functions, two double-quotes would mean "end of user input." Your demonstrated knowledge of Lisp suggests that you probably already know that, but I can't think of anything else without knowing more about the ChangeDimScale command.

  • Check if CHANGEDIMSCALE is LISP

    It looks like your CHANGEDIMSCALE command is probably a LISP routine making a number of command based calls.

    You could check for this by searching for it in the atoms family

    (Vle-member "C:CHANGEDIMSCALE" (atoms-family 1))

    If this returns T for true, then it's a LISP routine. If this is the case, then if you can find the file that its defined in, then you can edit it directly.

    Use EXPERT to control command prompts

    When making command calls it can be useful to set the EXPERT system variable to suppress additional prompting when something like a dimension style already exists.

    Site faviconEXPERT system variable - BricsCAD Lite & Pro | Bricsys Help Center

    In your case, you may find setting EXPERT = 5 before running CHANGEDIMSCALE will suppress the requirement to enter "Y" at the end.

    If you find this is the case and you've determined CHANGEDIMSCALE is a LISP function, then you could edit it to include setting and resetting of the EXPERT system variable.

    Jason Bourhill

    CAD Concepts Ltd
    cadconcepts.co.nz

  • I was mistaken.
    ChangeDimScale was a Lisp I wrote a long time ago.
    I am very sorry for the trouble.

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.