sadhu Posted February 25, 2010 Posted February 25, 2010 I'm using this code to measure distance with consecutive clicks. It is like the dist command but allows me to measure polylines (zig-zag), add predefined constants and insert a value form keyboard and the total (tot2) is displayed in a dcl window. I need help to insert this value (tot2) in the drawing in a position that would be determined by clicking on screen. This way I would eliminate the dcl window and the trouble to write the value (tot2) manually on the drawing. I need help to add error traps as well. v 300.1.1prad ;cumulative distance ;this routine is just like the Autocad Distance command with the ;exception that it allows you to pick more than 2 consecutive points. ;the routine will display the cumulative distance and the distance ;between the last two points picked on the command line. ;it will add predefined constants and ask for values to add to distance measured ;and show results in a dcl window ; (defun c:sq () (setvar "cmdecho" 0) (graphscr) (setq a1 0.30 a2 0.10 a3 0.10 tolleranza 0.20 ) (princ "Discesa ") (princ a1) (princ " Massetto_1 ") (princ a2) (princ) (princ " Massetto_2 ") (princ a3) (princ) (princ " Tolleranza ") (princ tolleranza) (princ) (setq p1 (getpoint "\nPick start point ") p2 (getpoint p1 "\nPick next point ") d1 (distance p1 p2) prdist (strcat "\nDistance: " (rtos d1)) ) (princ prdist) (setq p3 (getpoint p2 "\nPick next point or RETURN if done ")) (while p3 (setq d0 (distance p2 p3) d1 (+ (distance p2 p3) d1) p2 p3 prdist (strcat "\nDistance: " (rtos d0) ", Cumulative distance: " (rtos d1)) ) (princ prdist) (setq p3 (getpoint p2 "\nPick Next Point ")) ) (setq cumd (strcat "Distanza orrizontale --> " (rtos d1 2 2))) (prompt cumd) (princ) (setq miodist (getdist "\n Insert Height ")) (princ "\n The height is ") (princ (rtos miodist 2 2)) (princ) (setq tot2 (+ a1 a2 a3 tolleranza miodist d1)) (setq pcumd (strcat "Grand distance --> " (rtos tot2 2 2))) (princ "\n --> ") (prompt pcumd) (princ) ;(princ "\n la distance G.totale is ") ;(princ tot2) ;(princ) ;-------------start dialog------------ (setq dcl_id (load_dialog "hello_sp.dcl")) ; Load the DCL file. (if (not (new_dialog "hello_sp" dcl_id)) ; Initialize the dialog. (exit) ; Exit if this doesn't ; work. ) ;------------ set values in dialog box---- (set_tile "discesa" (rtos a1 2 2)) (set_tile "masetto1" (rtos a2 2 2)) (set_tile "salita" (rtos miodist 2 2)) (set_tile "tolleranza" (rtos tolleranza 2 2)) (set_tile "grand_dist" (rtos tot2 2 2)) (set_tile "grand_dist_" "GRAND TOTAL (SQ)") ;------------ end - set values in dialog box---- (start_dialog) ; Display the dialog ; box. (unload_dialog dcl_id) ; Unload the DCL file. (princ) ;------------------------ ) (princ "\nType sq to run Grand Distance(sq)") (princ) Quote
alanjt Posted February 25, 2010 Posted February 25, 2010 You can use something like this to add a text value, based on a specified point. (and (setq pnt (getpoint "\nSpecify Text placement point: ")) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 1 tot2) (cons 7 (getvar 'textstyle)) (cons 10 pnt) ) ;_ list ) ;_ entmakex ) ;_ and Quote
Lee Mac Posted February 25, 2010 Posted February 25, 2010 Sadhu, Read this: http://www.cadtutor.net/forum/showthread.php?t=9184 Quote
sadhu Posted February 25, 2010 Author Posted February 25, 2010 I edited my post. Is it ok now ? Quote
alanjt Posted February 25, 2010 Posted February 25, 2010 Yes [code][quote]Rules rules rules. [/quote] [/code] ................... Quote
sadhu Posted February 25, 2010 Author Posted February 25, 2010 Hi alanjt , I get this error. I just copied the code and pasted to the end of my lisp. Specify Text placement point: ; error: bad DXF group: (1 . 15.472) What does it mean ? Quote
Lee Mac Posted February 25, 2010 Posted February 25, 2010 Try this instead: (and (setq pnt (getpoint "\nSpecify Text placement point: ")) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 1 (rtos tot2 2 2)) (cons 7 (getvar 'textstyle)) (cons 10 pnt) ) ;_ list ) ;_ entmakex ) ;_ and Quote
alanjt Posted February 25, 2010 Posted February 25, 2010 Hi alanjt , I get this error. I just copied the code and pasted to the end of my lisp. What does it mean ? Sorry about that. I had just assumed you had/would convert it to a string. Try this instead: (and (setq pnt (getpoint "\nSpecify Text placement point: ")) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 1 (rtos tot2 2 2)) (cons 7 (getvar 'textstyle)) (cons 10 pnt) ) ;_ list ) ;_ entmakex ) ;_ and Thanks Lee. Quote
sadhu Posted February 25, 2010 Author Posted February 25, 2010 Thanks Lee:) Works perfect. Is text height managed by this ? (cons 10 pnt) Quote
alanjt Posted February 25, 2010 Posted February 25, 2010 Thanks Lee:) Is text height managed by this ? NO, that's the insertion point. For textsize: (cons 40 (getvar 'textsize)) or whatever you like. Quote
Lee Mac Posted February 25, 2010 Posted February 25, 2010 No, Textheight is set by your text style. You can have an override using: (cons 40 <height>) See here: http://autodesk.com/techpubs/autocad/acad2000/dxf/ Quote
alanjt Posted February 25, 2010 Posted February 25, 2010 No, Textheight is set by your text style. You can have an override using: (cons 40 <height>) See here: http://autodesk.com/techpubs/autocad/acad2000/dxf/ Huu azahh! Quote
sadhu Posted February 25, 2010 Author Posted February 25, 2010 Thanks again. Just did this and got what I wanted : (and (setq pnt (getpoint "\nSpecify Text placement point: ")) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 1 (rtos tot2 2 2)) (cons 7 (getvar 'textstyle)) (cons 10 pnt) (cons 40 0.1) ) ;_ list ) ;_ entmakex ) ;_ and Quote
alanjt Posted February 25, 2010 Posted February 25, 2010 Just for the record, if you specify the value instead of retrieving it from a variable, you can additionally call it like the following: '(40 . 0.1) Quote
Lee Mac Posted February 25, 2010 Posted February 25, 2010 Explanation of Alan's suggestion: http://www.cadtutor.net/forum/showpost.php?p=258390&postcount=20 Quote
sadhu Posted March 11, 2010 Author Posted March 11, 2010 I need to add two features to the code below: the text be visible along with the cursor before specifying "Text placement point" - so that I can see that the text does not overlap other objects nearby. be able to rotate Text (obviously not with the rotate command after insertion) (and (setq pnt (getpoint "\nSpecify Text placement point: ")) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") ;(cons 8 lay) (cons 1 (strcat "(" Edit1 Edit2 ")" (rtos tot2 2 2) Edit3)) (cons 7 (getvar 'textstyle)) (cons 10 pnt) (cons 40 0.08) ) ;_ list ) ;_ entmakex ) ;_ and Quote
Lee Mac Posted March 11, 2010 Posted March 11, 2010 I need to add two features to the code below:the text be visible along with the cursor before specifying "Text placement point" - so that I can see that the text does not overlap other objects nearby. This would only be possible either through a grRead loop, or using the move command with a pause, or perhaps using pasteclip. Quote
alanjt Posted March 12, 2010 Posted March 12, 2010 This would only be possible either through a grRead loop, or using the move command with a pause, or perhaps using pasteclip. Don't forget about ACET-SS-Drag-Move. I only suggest this to allow the user the ability of being able to utilize OSnaps normally and avoid the annoyances of a right-click if using Move..Pause. However, it does require Express Tools to be loaded. 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.