PDA

View Full Version : Osnap and Rubber-band line not appearing while routine is run


abain.117305
2007-03-20, 03:10 PM
I wrote a Lisp routine to draw a polyline connecting a series of user-selected points. When I just draw a polyline using the PLINE command the osnap selection indicator works properly and the polyline shows with a rubber-band line from the last point selected. But when I run the Lisp routine, the osnap selection indicator and the rubber-band line do not appear. I set the OSMODE value in the lisp routine to 8 (node). Any ideas about what might be preventing the osnap selection indicator and rubber-band line from displaying?

madcadder
2007-03-20, 03:48 PM
Would have to see the code to know for sure. Sounds like your are doing something other than GETPOINT.

abain.117305
2007-03-20, 04:19 PM
I am using ENTSEL because the routine is selecting AECC-POINTs (thus the OSMODE=8 for NODE), and then I extract other information from the elements database to use in my routine.

kennet.sjoberg
2007-03-20, 09:02 PM
I am using ENTSEL because the routine is selecting AECC-POINTs (thus the OSMODE=8 for NODE), and then I extract other information from the elements database to use in my routine.
..hmmm You can not affect ENTSEL with any OSMODE settings

the fastest way to get your code running, is to show it and let us tune it up.

: ) Happy Computing !

kennet

abain.117305
2007-03-21, 03:22 PM
Here's the code:

; SECTION_LINE.LSP

; Allows user to select survey points
; (as AECC_POINT elements) and then
; joins the points with a polyline and
; writes the appropriate station and
; elevation data to a text file.

; Written by: Al Bain
; Herbert, Rowland & Grubic, Inc.
; March 20, 2007

;-------------------------------------
(defun DELLERR (S)
(if (/= S "Function cancelled")
(princ (strcat "\nError: " S))
)
(setvar "cmdecho" OLD_CMD)
(setq *error* OLDERR)
(princ)
); end defun DELLERR

;-------------------------------------

(defun C:SL ()

(setq OLD_CMDECHO (getvar "cmdecho"))
(setq OLD_OSMODE (getvar "osmode"))
(setq OLD_AUTOSNAP (getvar "autosnap"))
(setq *error* dellerr)
(setvar "cmdecho" 0)
(setvar "osmode" 8)
(setvar "autosnap" 1)

;Have user enter a file name to store the station/elevation data
(setq al_fln (getfiled "SELECT FILE NAME" "" "TXT" 9))
(setq al_writefile (open al_fln "w"))

;Now begin the main loop

(setq al_line 0)
(setq al_loop 0)

(while (= al_loop 0)

(if (= al_line 0)
(setq al_point (entsel "\n Select a starting survey point: "))
(setq al_point (entsel "\n Select the next survey point (<ENTER> to end): "))
); end if

(if (/= al_point nil)
(progn
(setq al_pointname (car al_point))
(setq al_pointdata (entget al_pointname))
(setq al_pointtype (cdr (assoc 0 al_pointdata)))
(setq al_pointnumber (cdr (assoc 90 al_pointdata)))

(if (= al_pointtype "AECC_POINT")
(progn ;survey point
(setq al_basepoint (assoc 11 al_pointdata))
(setq al_basepoint (cdr al_basepoint))
(setq al_basex (car al_basepoint))
(setq al_basey (cadr al_basepoint))
(setq al_basez (caddr al_basepoint))
(if (= al_line 0)
(progn ;begin a new line
(setq al_startline (list al_basex al_basey))
(command ".pline" al_startline)
(setq al_station 0.0)
(setq al_stationdata (strcat (rtos al_station 2 2) "," (rtos al_basez 2 2)))
(write-line al_stationdata al_writefile)
(setq al_oldx al_basex)
(setq al_oldy al_basey)
(setq al_oldstation 0.0)
(setq al_line 1)
); end progn
(progn ;continue a line
(setq al_oldpoint (list al_oldx al_oldy))
(setq al_linepoint (list al_basex al_basey))
(command al_linepoint)
(setq al_incdist (distance al_oldpoint al_linepoint))
(setq al_station (+ al_oldstation al_incdist))
(setq al_stationdata (strcat (rtos al_station 2 2) "," (rtos al_basez 2 2)))
(write-line al_stationdata al_writefile)
(setq al_oldx al_basex)
(setq al_oldy al_basey)
(setq al_oldstation al_station)
); end progn
); end if
); end progn
(progn ;not a survey point
(princ "\n SELECTED ENTITY NOT A SURVEY POINT")
(princ "\n SELECT ANOTHER POINT: ")
); end progn
); end if
); end progn
(progn ;No point selected - end the line
(setq al_loop 1)
(command "")
(close al_writefile)
); end progn
); end if
); end while

(setvar "cmdecho" OLD_CMDECHO)
(setvar "osmode" OLD_OSMODE)
(setvar "autosnap" OLD_AUTOSNAP)

(princ)
); end defun

Avatart
2007-03-21, 03:45 PM
Two things; firstly, declare your variables. Secondly, with entsel there is no facility to rubber band, if you use getpoint, you can use a variable as a point to rubber band from, entsel does not have this functionality.

Tom Beauford
2007-03-21, 04:47 PM
You can use both easily enough.
(while (not (setq ss (ssget ":S:E" (list (cons 0 "AECC_POINT")))))
(setq PT2 (getpoint PT1 "\nNext point: "))
)

Please use Wrap [CODE] Tags # symbol in edit box and declare those variables.