lamensterms Posted September 6, 2011 Posted September 6, 2011 Hi guys, Ive got this attedit routine which some of you may have seen before, the only problem im having with it is it will round one of the inputs to the number of decimal places as set with LUPREC system variable. I would like to tell my routine to ignore the LUPREC setting and use the values exactly as they are input by the user. (DEFUN C:ssc () (setq ocmd (getvar "CMDECHO")) (prompt "\nSelect Title Block, Mark and Material List to be re-scaled... ") (COMMAND "ucs" "w") (setq sscpt1 '(0 0 0)) (setq sscsset1 (ssget)) (setq ss (ssget "X" (list (cons 0 "insert")(cons 2 "pdctitle")))) (setq ename (ssname ss 0)) (setq data (entget ename)) (setq ssccs (cdr (assoc 41 data))) [b] (SETQ sscds (getREAL "\nEnter Desired Scale : "))[/b] (COMMAND "scale" sscsset1 "" sscpt1 (/ sscds ssccs)) (COMMAND "dimscale" sscds) (COMMAND "ltscale" (* sscds 10)) (COMMAND "-style" "PDC_Prosteel" "isocp.shx" (* sscds 3.5) "1" "0" "NO" "NO") (setq ssctso (strcat "1:"(rtos ssccs))) [b] (setq ssctsn (strcat "1:"(RTOS sscds)))[/b] (COMMAND "ZOOM" "EXTENTS") (setq pt1 '( -500000000 -500000000 0)) (setq pt2 '( 500000000 500000000 0)) [b] (COMMAND "-attedit" "y" "pdctitle" "pdcSCALE" "" "w" PT1 PT2 "V" "r" ssctsn "")[/b] (COMMAND "graphscr") (COMMAND "ZOOM" "p") (setvar "CMDECHO" ocmd) (alert "Please remember to check/adjust SCALE value in Title Block") (princ) ) It is a routine for scaling a drawing sheet, i have marked the lines which i think are relevant in bold. The routine asks the user to input what scale they would like the DRG sheet at, the user enters the desired scale, then the routine will scale the sheet accordingly and also update the 'scale' field in the attributed title block. the problem is - is that if LUPREC is set to zero (0) - only whole numbers will be displayed in title block. if user requires a scale of 1:12.5 - it will be displayed as 1:13 (is LUPREC is 0). If LUPREC is set to 1 (or greater) - the result in the title block will be displayed with decimal places (even if a whole/round number is entered). 1:10 is displayed as 1:10.0. Thanks for any help guys. Quote
BlackBox Posted September 6, 2011 Posted September 6, 2011 Three options that stand out to me are to: 1. Incorporate a LUPREC variable change and error checking. 2. Use GETSTRING in lieu of GETREAL then convert your STRING to REAL to have exact value for scaling. 3. Use GETKWORD to relegate the user to predefined scale options. Hope this helps! Edit: Localize your variables :wink: Quote
lamensterms Posted September 6, 2011 Author Posted September 6, 2011 Thanks for the quick reply RenderMan. And thank you for all your tips - I am still quite new to LISP so im always learning the DOs and DON’Ts. I had thought about using GETSTRING, then converting SRING to REAL, but after a few minutes of googling I couldn’t find the right function. Then I stumbled across and old thread here and found ATOF. Thanks again for all your help. Ill let you know how I go. Cheers. Quote
BlackBox Posted September 6, 2011 Posted September 6, 2011 (edited) No worries; we all start somewhere... Sometimes all we need is a little nudge in the right direction. :wink: Cheers! Edited September 6, 2011 by BlackBox Quote
BIGAL Posted September 7, 2011 Posted September 7, 2011 I have a Release 12 Autolisp Programmers Reference manual my bible for quick look ups but thought have a look at "help" the elctronic version a bit more difficult to flick pages. Found you can get a summary list pretty easy Contents, pick Customization Guide, Autolisp, Autolisp reference and a A-Z list appears you you can do two things pick a alphabet character and see a summary of commands or on top right theres a these will step one at a time and give more info for each command, the ^ takes you up the alphabet tree its a bit clumsy but sometimes you know the command and just dont type it right. It is reasonably quick to jump pages. Search unfortunatley can return 20 soloutions for "string real" VLIDE obviously has the help also. Quote
lamensterms Posted September 7, 2011 Author Posted September 7, 2011 thanks a lot for the tip BigAl. I agree that sometimes it is a bit easier to just flip through pages. But that reference list will come in very handy (also for learning functions i didnt know existed). The cats had a pretty good win last week... i hope they can continue that form into the finals. Thanks again guys. Quote
irneb Posted September 8, 2011 Posted September 8, 2011 I generally use my old 2008's help in preference to the online / offline help. There's close to the same thing, it's just a lot more responsive & the search actually works if you start it from ACad help itself (not from within VLIDE) - unlike the useless search on the new help system (better to use Google to search on it). And unlike the new help system, you still have the ActiveX reference to look at - try figuring out how something like the BoundingBox method works without that! Quote
BlackBox Posted September 8, 2011 Posted September 8, 2011 Wrote this a little while ago, for this very purpose :wink:: (defun c:LISPDD () (c:LISPDeveloperDocumentation)) (defun c:LISPDeveloperDocumentation () (princ "\rLISP DEVELOPER DOCUMENTATION ") (vl-load-com) ((lambda (vrsn) (help (strcat "acad_dev" (cond ((vl-string-search "16.2" vrsn) "162") ; 2006 ((vl-string-search "17.0" vrsn) "170") ; 2007 ((vl-string-search "17.1" vrsn) "171") ; 2008 ((vl-string-search "17.2" vrsn) "172") ; 2009 ((vl-string-search "18.0" vrsn) "180") ; 2010 ((vl-string-search "18.1" vrsn) "181") ; 2011 ((vl-string-search "18.2" vrsn) "182"))))) ; 2012 (vlax-product-key)) (princ)) Quote
lamensterms Posted September 21, 2011 Author Posted September 21, 2011 Hi guys, I know it been a while - just wanted to let you know that i finally got around to modifying the routine - using a STRING input and then using ATOF. Works well now - exactly as i need. Thanks again. Quote
BlackBox Posted September 21, 2011 Posted September 21, 2011 Thanks for following up, and congrats! Quote
Recommended Posts
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.