Jump to content

Recommended Posts

Posted (edited)

I am a novice in VLISP programming. By using examples of code written by others, I craeted the following code. Here's what I want to achieve with it.
When the value of CANNOSSCALE is changed, I want to trigger a change of DIMSCALE. And then Regen the drawing. In the code below, the line for regenerating the drawing is executed. But the line for changing DIMSCALE is not executed. It also does not produce any error.

 

(vl-load-com)
(if (null casr)
  (setq casr (vlr-sysvar-reactor nil '((:vlr-sysvarchanged . rgnlt))))
)
(defun rgnlt (casr cl)
    (cond
        ((= (car cl) "CANNOSCALE")
            (vl-cmdf "dimstyle" "_R" (strcat "SR" (vl-princ-to-string (fix (/ 1 (getvar "CANNOSCALEVALUE"))))))
            (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)
        )
    )
)

 

Edited by SLW210
Added Code Tags!
Posted (edited)

sadly I use dim / dimstyle pretty much never , my work is mostly about electrical schematics , loop diagrams and terminal lists

that being said , command line is executed but vl-cmdf first checks if command is valid before doing something.

Maybe replace vl-cmdf with command and you see what i mean.

 

Anyways , think "dimstyle" should be "-dimstyle" to make use of command line version rather than dialog version.

When I typed 'cannoscale' I got "1:1" , oh , this has something to do with scale , ok, I type 1:10 and see what happens... sure cannoscalevalue became 0.1

so , -dimstyle  , _R is restore and the value your routine  gave was SR10 (or SR1). I assume this kinda works like the text style command and style must be present in drawing?

 

Hope his helps

(and hello mhupp , saw you responded while I was typing 😄 )

 

gonna sleep now , it's 4 in the morning for me 😴 💤

 

🐉

Edited by rlx
Posted (edited)

What is the value of cl? No cl then (car cl) is nil

 

I don't use reactors either, but when calling a function normally you'd need to specify the variables used so to use

 

(defun rgnlt (casr cl)

 

 

You'd normally call it with

(rgnlt casr cl)

Though not sure if this is different with reactors

Edited by Steven P
Posted
6 hours ago, aksha said:

@SLW210 Yes, I do use AutoCAD LT 2024 which is LISP enabled.

It has limits, so it is something that needs clarified.

 

Also, you show AutoCAD LT 2023 in your profile.

  • Like 1
Posted

Thank you all for your help. I have revised my code per the attached and it works as I intended.

CannScl.lsp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...