Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set CANNOSCALE via DIMSCALE Value

16 REPLIES 16
Reply
Message 1 of 17
cgentile
7016 Views, 16 Replies

Set CANNOSCALE via DIMSCALE Value

Hey all, I could use some input on this one. I'm trying to make an easy transition to annotative objects. We are familiar with dimscale values, but I want that translated to an annotative scale. I'm using a conditional to match the dimscale value to an annotative scale. I was able to achieve the desired result with the standard metric scales, but ran into problems with the standard imperial scales. 

 

Some issues that are bound to be faced are having non-standard annoatative scales, so having a way to create new annotative scales. One work around would be to have these created in the template...

 

Another issue would be working with metric and imperial scales. There would likely be an if statement to get the current units as part of the metric and imperial conditional statements, or is there another way to do this?

 

Thanks, I appreciate the help!

16 REPLIES 16
Message 2 of 17
dbroad
in reply to: cgentile

Recommendations:

1. Once you switch to annotative scaling, don't use dimscale to drive the process.  There is easy access to annotation scales on the status bar.  Use that control.  

2. When using annotative scaling, dimscale should remain 1.  Any other dimscale sets an override on the dimension style which interferes with that dimstyles global use under annotative scaling. Current dimstyles, text styles, and mleader styles should all be annotative.

3. Don't try to get a single program to work with metric and imperial scales.  Only one type should be in effect for a drawing due to drawing units issues.  A dimscale of 2 should be "6\" = 1'-0\"", not "2:1".  If your metric listing was correct, if d=2, then cannoscalename should be "1:2", not "2:1", etc.

4. One of the main disadvantage with the annotation scaling system is that it uses names, not numbers.  That is also its main advantage (as some see it).  So often there is more than one annotation scale per dimscale or per annoscalevalue(they are reciprocals of one another).  "1:1" and "1'-0\" = 1'-0\"" relate to dimscale of 1, "1:2" and "6\" = 1' - 0"\" are both related to dimscale of 2. 

 

If I was making the transition today, I would change my programs and library content top to bottom to use annotative scaling rather than by patching my existing programs.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 17
cgentile
in reply to: dbroad

Thanks, familiar with the status bar and selecting scales from there, but many at the office are set on using scale values. The reason I want to use scale vlaues to determine the annotative scale would be to ease the transition from non-annotative objects to annotative objects without causing too much confusion as to how to change it. Personally, I rather type in a scale value than sift through the scale list.

 

I developed the code a bit further, but can't get it to run. Anyone care to catch my error?

Message 4 of 17
dbroad
in reply to: cgentile

Each dimscale has multiple possible annotation scales.  Either make the transition or don't but don't soft pedal it or create a bunch of crutches.

Architect, Registered NC, VA, SC, & GA.
Message 5 of 17
ASCunningham
in reply to: cgentile

I've incorporated this in our .mnl file

 

(defun cannoscale ()
(cond
((= (getvar "dimscale") 1)(setq cannoscl "1:1"))
((= (getvar "dimscale") 12)(setq cannoscl "1\" = 1'-0\""))
((= (getvar "dimscale") 24)(setq cannoscl "1/2\" = 1'-0\""))
((= (getvar "dimscale") 32)(setq cannoscl "3/8\" = 1'-0\""))
((= (getvar "dimscale") 48)(setq cannoscl "1/4\" = 1'-0\""))
((= (getvar "dimscale") 64)(setq cannoscl "3/16\" = 1'-0\""))
((= (getvar "dimscale") 96)(setq cannoscl "1/8\" = 1'-0\""))

....

....

....

(t nil)
(setvar "cannoscale" cannoscl)))
(cannoscale)

Message 6 of 17
Lee_Mac
in reply to: ASCunningham

Personally, I would suggest an association list, e.g.:

 

(
    (lambda ( / scl )
        (if
            (setq scl
                (cdr
                    (assoc (getvar 'dimscale)
                       '(
                            (01 . "1:1")
                            (12 . "1\" = 1'-0\"")
                            (24 . "1/2\" = 1'-0\"")
                            (32 . "3/8\" = 1'-0\"")
                            (48 . "1/4\" = 1'-0\"")
                            (64 . "3/16\" = 1'-0\"")
                            (96 . "1/8\" = 1'-0\"")
                        )
                    )
                )
            )
            (setvar 'cannoscale scl)
            (prompt "\nDIMSCALE does not correspond to Annotation Scale.")
        )
        (princ)
    )
)

 

Message 7 of 17
ASCunningham
in reply to: Lee_Mac

Thanks, your approach is better. I've been trying to incorporate your "autoblock break" lisp into an existing button. It there some way to modify your code below to not prompt for a user selection and just use "last" inserted block?

 

(defun c:abbs ( / *error* inc rot sel )

    (defun *error* ( msg )
        (LM:endundo (LM:acdoc))
        (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
            (princ (strcat "\nError: " msg))
        )
        (princ)
    )
    
    (setq rot (= "ON" (getenv "LMac\\ABBRotation")))
    (if (setq sel (ssget "_:L" '((0 . "INSERT"))))
        (progn
            (LM:startundo (LM:acdoc))
            (repeat (setq inc (sslength sel))
                (LM:AutoBlockBreak (ssname sel (setq inc (1- inc))) rot)
            )
            (LM:endundo (LM:acdoc))
        )
    )
    (princ)

 

Message 8 of 17
Lee_Mac
in reply to: ASCunningham


@iam4phils wrote:

Thanks, your approach is better. I've been trying to incorporate your "autoblock break" lisp into an existing button. It there some way to modify your code below to not prompt for a user selection and just use "last" inserted block?


Certainly -

 

To use the last object added to the current layout (if a block), you can use:

 

(defun c:abbl ( / sel )
    (if
        (setq sel
            (ssget "_L"
                (list '(0 . "INSERT")
                    (if (= 1 (getvar 'cvport))
                        (cons 410 (getvar 'ctab))
                       '(410 . "Model")
                    )
                )
            )
        )
        (LM:AutoBlockBreak (ssname sel 0) (= "ON" (getenv "LMac\\ABBRotation")))
        (princ "\nLast object created was not a block.")
    )
    (princ)
)

 

To use the last block inserted (regardless of other objects created after the last created block), you can use:

 

(defun c:abbl ( / sel )
    (if
        (setq sel
            (ssget "_X"
                (list '(0 . "INSERT")
                    (if (= 1 (getvar 'cvport))
                        (cons 410 (getvar 'ctab))
                       '(410 . "Model")
                    )
                )
            )
        )
        (LM:AutoBlockBreak (ssname sel 0) (= "ON" (getenv "LMac\\ABBRotation")))
        (princ "\nNo blocks found in the current layout.")
    )
    (princ)
)

 

For others reading the thread - here is a link to my Auto Block Break program.

 

Lee

Message 9 of 17
ASCunningham
in reply to: Lee_Mac

That was what I needed thanks. Sorry for creating two differnet discussions on this, Don't now if you can move it out to be its own seperate thread.  Once again THANK YOU!

Message 10 of 17
Lee_Mac
in reply to: ASCunningham

You're welcome! Smiley Happy

 

A forum moderator would probably need to take care of moving the off-topic posts to a new thread if required.

 

Lee

Message 11 of 17
bhull1985
in reply to: Lee_Mac

Hey Lee,

How would that Abbl program know how to distinguish from the first block inserted into model space from the last block inserted into model space using the "_X" filter?

Thanks 🙂

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 12 of 17
Lee_Mac
in reply to: bhull1985

The "_X" filter causes ssget to iterate directly over the drawing database and hence returns a selection set of entities in the reverse of the order in which they were created.

Message 13 of 17
bhull1985
in reply to: Lee_Mac

That'd explain it!

And would also be why I've seen (reverse SelSetVar) quite often following SSget calls.

 

(well, occasionally)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 14 of 17
Lee_Mac
in reply to: bhull1985


@bhull1985 wrote:

And would also be why I've seen (reverse SelSetVar) quite often following SSget calls.


I doubt it - that would error... Smiley Wink

Message 15 of 17
bhull1985
in reply to: Lee_Mac

Sorry, I had meant if someone were to place the enames of objects gathered with a call to SSget into a list, and then reverse that........wouldn't it show the first blocks inserted, using the previous code..first to last, in that case?

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 16 of 17
Lee_Mac
in reply to: bhull1985


@bhull1985 wrote:

Sorry, I had meant if someone were to place the enames of objects gathered with a call to SSget into a list, and then reverse that........wouldn't it show the first blocks inserted, using the previous code..first to last, in that case?


Yes Smiley Happy

Message 17 of 17
latungkts
in reply to: Lee_Mac

bro help me to add more function to your code. 

For example in my drawing , there is some dimstyle in used that named as 1-50, 1-75, 1-100 and the current dimstyle is 1-25 and my cannoscale list in this drawing is 1/25, 1/50, 1/75, 1/100....

and i have this lisp ( attachment file below ) to pick a dimstyle in drawing and set it to be current dimstyle.i want to combine it with your code to change both dimstyle and cannoscale to match each other.

example : current dimstyle is 1-25 >>>> pick a dimstyle in drawing ( 1-50 ( overall scale factor is 50)1-100( overall scale factor is 100)...to be currnet dimstyle also change cannoscale to 1/50. 1/100... ( cannoscale list will be change to be match dimstyle )

sorry for my bad english .

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost