TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: nini007 on November 21, 2018, 02:29:49 PM

Title: Micro command
Post by: nini007 on November 21, 2018, 02:29:49 PM
Hello,

I allow myself to solicit the forum again :-)
I have a macro command or it converts several parameters at once.
It works well unfortunately in the end I have a window (F2) that opens.

Could anyone tell me where my mistake is?

Code: [Select]
^c^cltscale;1; ^c^cDIMSCALE;1; ^c^cDIMLUNIT;2; ^c^c-units;2;2;1;1;0.0;N; ^c^c'_insunits;5; ^c^cINSUNITSDEFSOURCE;5; ^c^cINSUNITSDEFTARGET;5;^c^cscu;g;^c^c

thank you in advance
Best regards
Title: Re: Micro command
Post by: kpblc on November 21, 2018, 03:14:39 PM
What is the command scu? My AutoCAD 2018 doesn't know this command.
And you can user macro like this (I didn't check it!):
Code: [Select]
^C^Cltscale;1;dimscale;1;dimlunits;2;lunits;2;luprec;2;aunits;1;auprec;1;insunits;5;insunitsdefsource;5;insunitsdeftarget;5;
Title: Re: Micro command
Post by: nini007 on November 22, 2018, 06:09:26 AM
Hello,

Yes thanks your code works :-D.
You with removed the "^C^C", well seen I had not thought :grinwink:.
The SCU in French is the coordinate system, I think in English it's USC.
In fact I would like the coordinate system to be set to general.
Unfortunately at the end I have the window F2 that appears.

thank you in advance  :-)
Best regards
Title: Re: Micro command
Post by: kpblc on November 22, 2018, 06:30:45 AM
Do you mean "World" coordinate system? In this case macro will be like this:
Code: [Select]
^C^Cltscale;1;dimscale;1;dimlunits;2;lunits;2;luprec;2;aunits;1;auprec;1;insunits;5;insunitsdefsource;5;insunitsdeftarget;5;_.ucs;_w;I think the better way is to use lisp:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:normalize-sys-coords (/ sys)
  2.   (foreach item '(("ltscale" . 1)
  3.                   ("dimscale" . 1)
  4.                   ("dimlunits" . 2)
  5.                   ("lunits" . 2)
  6.                   ("luprec" . 2)
  7.                   ("aunits" . 1)
  8.                   ("auprec" . 1)
  9.                   ("insunits" . 5)
  10.                   ("insunitsdefsource" . 5)
  11.                   ("insunitsdeftarget" . 5)
  12.                   ;; <Add any system variable you want to 'normalize'
  13.                   )
  14.     (if (getvar (car item))
  15.       (setvar (car item) (cdr item))
  16.       ) ;_ end of if
  17.     ) ;_ end of foreach
  18.   ;; To make command 'invisile'
  19.   (setq sys (vl-remove nil
  20.                        (mapcar (function (lambda (x / tmp)
  21.                                            (if (setq tmp (getvar (car x)))
  22.                                              (progn (setvar (car x) (cdr x)) (cons (car x) tmp))
  23.                                              ) ;_ end of if
  24.                                            ) ;_ end of LAMBDA
  25.                                          ) ;_ end of function
  26.                                '(("sysmon" . 0) ("cmdecho" . 0) ("menuecho" . 0) ("nomutt" . 1))
  27.                                ) ;_ end of mapcar
  28.                        ) ;_ end of vl-remove
  29.         ) ;_ end of setq
  30.   (vl-cmdf "_.ucs" "_w")
  31.   ;; Restore system variables changed to make command 'invisible'
  32.   (foreach item sys (setvar (car item) (cdr item)))
  33.   (princ)
  34.   ) ;_ end of defun
Title: Re: Micro command
Post by: nini007 on November 22, 2018, 03:31:47 PM
Hello,

Thank you for your help, your lisp works flawless  :smitten:
It is simpler than my order which was long as an arm  :uglystupid2:

Best regards