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

Some lisp modification for coordinate setting

23 REPLIES 23
SOLVED
Reply
Message 1 of 24
lai
Advocate
3571 Views, 23 Replies

Some lisp modification for coordinate setting

Hi all,  i just come across a lisp and i find it quite usefull,but then i wish to modify it abit and i need help as i am not a programmer and familiar with lisp. I have attach a sample of the lisp and jpeg to show what i require.basically all i need is the leader to be in multileader type. Is it possible? Additionally, can i set by default the coordinates to be shown in just 2 decimals?

23 REPLIES 23
Message 2 of 24
Moshe-A
in reply to: lai

try this buddy...

 

Moshe

 

Message 3 of 24
diagodose2009
in reply to: lai

This is my solution version..

Please you load my application lisp and enter the command Q2 [ enter]

If you need the modifications please send to me the private  message...........

 

Message 4 of 24
lai
Advocate
in reply to: Moshe-A

Dear Moshe,

I just give it a try on the lisp..i think there might be a bug.. After i load your lisp,it ask me pick a coordinate point, and after i pick a point, it will ask me to pick text location.

 

Now at this point, i notice it "INVALID INPUT".. Then i just simply try to pick a point again on the screen, it will prompt me to enter text..it will not automatic show me the coordinate point..

 

Actually, my previous lisp is quite ok already, but i just need the leader to be in "MULTILEADER" type and coordinates shown to be always in 2 decimal points.

Message 5 of 24
Moshe-A
in reply to: lai

Hi,

 

1. i have test the lisp (again) and it works very good.

    (no error no invalid input)

 

2. After loading it you need to invoke it by entering CXY command

 

3. i made minor correction to it (maybe this will help) download the new file

 

4. yes i did make it to be 2 decimal points

 

5. i was wondering, why do you need it to be MLEADER?

 

Moshe

 

Message 6 of 24
lai
Advocate
in reply to: Moshe-A

Dear Moshe,

Thanks for the revise new lisp..Anyway, i give it a try, it still the same result..i have attach along the step by step print screen as for your reference.Additionally i also attach along the drawing for your testing. I am not sure what is the problem with mine here.

 

The reason i need it to be multileader is because i have another lisp that will automatic select all leaders and multileaders to be change to a layer call "Dimension", but then is as what previously lisp done, the coodinate text will not  be change to my desire layer and only the leaders be change.

Message 7 of 24
Moshe-A
in reply to: lai

HI,

 

I think now i know were your problem  is and i will do some more checking tonight and

send you a fix

 

Moshe

 

Message 8 of 24
lai
Advocate
in reply to: Moshe-A

Dear Moshe,

Thanks alot for your help....

Message 9 of 24
hmsilva
in reply to: lai

Lai, try

 

 (setq txtx (strcat "X" (rtos (car pt1) 2 2)))
 (setq txty (strcat "Y" (rtos (cadr pt1) 2 2)))
 (setq txt (strcat txtx"\n"txty))
 (command "_.mleader" pt1 pt2 txt)

 

Cheers

Henrique

EESignature

Message 10 of 24
pbejse
in reply to: lai


@lai wrote:

Hi all,  i just come across a lisp and i find it quite usefull,but then i wish to modify it abit and i need help as i am not a programmer and familiar with lisp. I have attach a sample of the lisp and jpeg to show what i require.basically all i need is the leader to be in multileader type. Is it possible? Additionally, can i set by default the coordinates to be shown in just 2 decimals?



It depends on your Mleader settings . With Contents First and with  landing settings set.

*NOTE* i swap the prompt to Text location first 

 

(defun C:cxy  (/ oldecho pt1 pt2 txtx txty)
      (setq oldecho (getvar "cmdecho"))
      (setvar "cmdecho" 0)
      (setq pt2 (getpoint  "\nPick text location: "))
      (if pt2
            (progn
                  (setq pt1 (getpoint pt2 "\nPick coordinate point: "))
                  (if pt1
                        (progn
                              (setq txtx (strcat "X="
                                                 (rtos (car pt1)
                                                       2
                                                       2)
                                                 " "))
                              (setq txty (strcat "Y="
                                                 (rtos (cadr pt1)
                                                       2
                                                       2)
                                                 ))
                              (command
                                    "mleader"  pt2 "@"
                                    (strcat txtx "\\P"  txty)
                                     pt1
                                    "")
                              )
                        )
                  )
            )
      (setvar "cmdecho" oldecho)
      (princ)
      )

 

with this one , you'll be prompeted for landing location: with landing setting off

 

(command "mleader"  pt2 "@" (strcat txtx "\\P"  txty) pause pt1)       

                           

Message 11 of 24
Moshe-A
in reply to: lai

Lai,

 

first, it looks like you set the mleader Options to use 3 points (Maxpoint) instead of the default 2 points

so if you fix it the lisp will work

 

second, be aware of mleader command prompt. the default asks for the arrowHead first (H option)

but if you specify to draw the leader Landing first? (L option) the prompt is changed and stay that

as the default for the next invokation of mleader (but still the lisp will work if the maxpoint is 2)

weird that autodesk did not give us a sysvar to know what is the current mleader prompt???

 

Cheers,

Moshe

 

 

 

Message 12 of 24
lai
Advocate
in reply to: pbejse

Dear Pbejese,

I just give a try, but then somehow error below come out:-

 

Command: Command: (LOAD "C:/Users/DRE31-Lai/Downloads/test 2 pbejse.lsp") C:CXY

Command: cxy

Pick text location: Pick coordinate point: ; error: too many arguments

Command:

 

Anyway, i have attach a file to show my current multileader setting.Additonally, i wonder is the lisp can be modify to be two with different style as shown.

Message 13 of 24
lai
Advocate
in reply to: Moshe-A

Dear Moshe,

Thanks for the help..Sigh, too bad that can't have 3 points for multileader..Anyway, you think if can have another lisp that can do what i show in my latest attach file?

Message 14 of 24
pbejse
in reply to: lai


@lai wrote:

Dear Pbejese,

I just give a try, but then somehow error below come out:-

 

Command: Command: (LOAD "C:/Users/DRE31-Lai/Downloads/test 2 pbejse.lsp") C:CXY

Command: cxy

Pick text location: Pick coordinate point: ; error: too many arguments

Command:

 

Anyway, i have attach a file to show my current multileader setting.Additonally, i wonder is the lisp can be modify to be two with different style as shown.


I dont see that error message here lai.

 

(defun cxy  (flg / oldecho pt1 pt2 txtx txty flg)
      (setq oldecho (getvar "cmdecho"))
      (setvar "cmdecho" 0)
      (setq pt2 (getpoint  "\nPick text location: "))
      (if pt2
            (progn
                  (setq pt1 (getpoint pt2 "\nPick coordinate point: "))
                  (if pt1
                        (progn
                              (setq txtx (strcat "X" (rtos (car pt1)
                                                       2 2)))
                              (setq txty (strcat "Y" (rtos (cadr pt1)
                                                       2  2)))
                              (command "mleader"  pt2 "@"
                                    (if flg (strcat txtx "\\P"  txty)
         (strcat txtx ","  txty))
                                         pt1 "")      
                              )
                        )
                  )
            )
)
(defun c:cxy1 nil (cxy T))
(defun c:cxy2 nil (cxy nil))

 

command: cxy1 for this format\

 X63.85

Y-22.58

command: cxy2 for this format 

 X63.85,Y-22.58

 

Again. Contents first mode for Mleader, Automatic includie landing is set, Landing distance 5.00 (put your on value)

 

Now to ensure you are on content first mode:

 

(setq txty (strcat "Y" (rtos (cadr pt1)
                                                       2  2)))
(command "_mleader")(vl-catch-all-apply (function (lambda () (command "_content"))))    

 (command pt2 "@"  (if flg (strcat txtx "\\P"  txty)  (strcat txtx ","  txty)) pt1 "")
                                     ) 

)

 

HTH

Message 15 of 24
Moshe-A
in reply to: lai

Ofcurse you can have 3 points (or 4 / 5  as many you like) but you have

to decide it in advance (cause the CXY command must know it)

 

or

 

each time you invoke CXY the lisp will issue a prompt that ask you to enter this value

which it's very annoing

 

i would prefer the first option

 

so just tell me how many points you would like it to be and remember

that if you choose  3? you would not have it with 2 or 4

 

Moshe

 

Spoiler
 

 

Message 16 of 24
lai
Advocate
in reply to: Moshe-A

Dear Moshe,

Thanks..I need it to be 3 points and start with coordinate point pick up first then only follow by the text placement...

If possible i need two lisp and do two function as i previously post. Thanks in advance.

Message 17 of 24
lai
Advocate
in reply to: pbejse

Dear Pbejse,

I try your code again..Anyway, i got some new idea..i am more prefer that the lisp to be written that we pick point of the require coordinate first and then only follow by the text placement. Reason is i can adjust and see where i should place the text of the coordinates. Wonder if you can help to modify it abit again?

 

Additionally, i have given it a few times try and i notice some result:

 

1) Even though in "Landing Setting" area i didn't check any of the options,and at the using max 3points constraint option, i still can run the lisp and only thing is at the end result it shows as below :-

 

Command: CXY1

Pick text location:

Pick coordinate point:  <Ortho off>

Point or option keyword required.

nil

Command: cxy2

Pick text location:

Pick coordinate point:

Point or option keyword required.

nil

 

 

Message 18 of 24
Moshe-A
in reply to: lai

Lai OK

 

attached CXY.LSP

 

it includes CXY2 command for 2 points

          and CXY3 command for 3 points

 

hope atlast you will be satisfy

 

Moshe

 

Message 19 of 24
lai
Advocate
in reply to: Moshe-A

Dear Moshe,

Hi, thanks for the revise lisp..anyway i wish to have some slightly modification..can i revise the lisp to be with just 3 points for the multileader and with the option of style as i attach here with style 1 & style 2...Previously Pbejse have one lisp, but then it was require to place text first then only pick coordinates.

Message 20 of 24
Moshe-A
in reply to: lai

Here it is

 

remeber to set the correct prompt for the mleader command before using CXY? commands

(e.g Leader Landing first and Content last)

cause there is no way the lisp can know what is the current mleader prompt

 

Moshe

 

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

Post to forums  

Autodesk Design & Make Report

”Boost