Jump to content

Need Help for this Lisp Routine...


aaryan

Recommended Posts

Hi All,

I am using civil3d and i have downloaded a lisp routine to get lat long value on any point i click, i am getting the values in decimal degrees but i want it in degree minutes and even in DMS if necessary. I have tried to edit this routine to get values in DMS but not successful it gives a syntax error i have tried my to edit as per my knowledge but get error always..

 

Below is the routine originally downloaded:

(defun c:get_ll (/ as_cor ll lat lon pkpt)

(setq as_cor (ade_projgetwscode))
(if (/= "" as_cor) ;checks for an assigned coordinate system
(progn
(ade_projsetsrc as_cor)
(ade_projsetdest "LL84") ; uses lat/lon with no datum change as
needed

(while (not (setq pkpt (getpoint "\nPick Desired Point: "))))
(progn
(setq ll (ade_projptforward pKpt))
(setq lat (car ll)
lon (car (cdr ll))
)
(setq desc (ade_projgetinfo "LL84" "description"))


([color="red"]princ[/color] (strcat "Lat: " (rtos lat 2 6)
"\nLong:"(rtos lon 2 6)
"\n Converted from: "as_cor
"\n Converted to: " desc
)
)
(princ)
);progn

);progn
;(alert "NO COORDINATE SYSTEM ASSIGNED TO THIS DRAWNING")
(asg_coor)
);if
);defun


(defun asg_coor (/ req )
(initget "Yes No" )
(setq req (getkword "No Coordinates Assigned to this MAP, Do you want to
Assign them now? No: "))
(if (= nil req) (setq req "Yes"))
(if (= req "Yes")
(progn

(command "ADESETCRDSYS")
(if (/= "" (ade_projgetwscode))
(C:get_ll)
(Alert "\nFailed to Assign Coordinates")
);if

);progn

(princ "\nGood Bye")
);if
(princ)
);defun

 

the highlighted princ command was originally the "LABEL" function and it was giving an error. i changed it to the princ function and i made it work for me.

 

Below here is what i have edited and not even completed because i wanted to check whether i am going correct or not. As i was getting an error i came here to get help. Any help would be appreciable..Thanks in advance..

 

(defun c:geo (/ as_cor ll lat lon pkpt)

(setq as_cor (ade_projgetwscode))
(if (/= "" as_cor) ;checks for an assigned coordinate system
(progn
(ade_projsetsrc as_cor)
(ade_projsetdest "LL84") ; uses lat/lon with no datum change as
needed

(while (not (setq pkpt (getpoint "\nPick Desired Point: "))))
(progn
(setq ll (ade_projptforward pKpt))
(setq lat (car ll)
lon (car (cdr ll))
)
(setq desc (ade_projgetinfo "LL84" "description"))
(setq latd (rtos lat 2 6)
     lond (rtos lon 2 6))
(setq latdegr (fix latd)
(setq latmins (fix (* 60 (- lat latdegr))))
(setq latsecs (* 60(- (* 60 (- lat latdegr)) (fix (* 60 (- lat latdegr))))))
)

(princ (strcat "Lat: " (itoa latdegr) (itoa latmins) (itoa latsecs)
"\nLong:" lond
"\n Converted from: "as_cor
"\n Converted to: " desc
)
)
(princ)
);progn

);progn
;(alert "NO COORDINATE SYSTEM ASSIGNED TO THIS DRAWNING")
(asg_coor)
);if
);defun


(defun asg_coor (/ req )
(initget "Yes No" )
(setq req (getkword "No Coordinates Assigned to this MAP, Do you want to
Assign them now? No: "))
(if (= nil req) (setq req "Yes"))
(if (= req "Yes")
(progn

(command "ADESETCRDSYS")
(if (/= "" (ade_projgetwscode))
(C:geo)
(Alert "\nFailed to Assign Coordinates")
);if

);progn

(princ "\nGood Bye")
);if
(princ)
);defun

Sorry for my english.

Edited by SLW210
Link to comment
Share on other sites

One point is that Fix only works on a number, and you have got it working with "latd" which you have just made to be a string. :cry:

 

There may be other points, but I am not expert enough.

Link to comment
Share on other sites

First, please use

 when posting code.

 

Second, please post LISP questions in the [b]AutoLISP, Visual LISP & DCL[/b] forum.

 

Third, do not forget to localize the "latd" symbol.

 

Fourth, and this is a big one, you say you downloaded this code... so where is the attribution from the original author?

Link to comment
Share on other sites

thank YOU Eldon and thank you renderman and sorry for my mistakes while posting as i posted lisp routine first time so i didnt know i should use all these things but next time i will take care of it..Shall i again post it in AutoLISP forum.

Link to comment
Share on other sites

thank YOU Eldon and thank you renderman and sorry for my mistakes while posting as i posted lisp routine first time so i didnt know i should use all these things but next time i will take care of it..Shall i again post it in AutoLISP forum.

 

No worries; we all make mistakes. :)

 

Do not create a duplicate thread... a Moderator will be along shortly to move this thread for us. :wink:

Link to comment
Share on other sites

Only if asked nicely. I might even do the # tags.

 

Relocated

 

Fair enough. :lol: LoL

 

Tags are appreciated as well.

 

Cheers! :beer:

Link to comment
Share on other sites

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...