spiker7221 Posted March 21, 2013 Posted March 21, 2013 This may be a crazy question...but here goes. I create a simple linetype based hatch pattern. I explode it in to individual lines and label each line with text showing the length. My current LISP routine accomplishes this with SSGET, but only by manually selecting them using crossing or window. ?#1...Is it possible to create the selection set of the lines inside the hatch before or after it is exploded? ?#2...Is it possible to draw the lines with a spacing offset inside this polyline area/boundary? Thanks for the help Mike in Dallas Quote
Lee Mac Posted March 21, 2013 Posted March 21, 2013 Welcome to CADTutor Mike. #1...Is it possible to create the selection set of the lines inside the hatch before or after it is exploded? Yes, collect and store a pointer to the last entity added to the drawing database before the hatch is exploded by a call to the entlast function, then step through all entities added to the drawing database following the hatch explosion using the entnext function, called with the pointer to the previous last entity. #2...Is it possible to draw the lines with a spacing offset inside this polyline area/boundary? Yes, this is also possible; given a line vector to determine the angle of the lines, the intersectwith method may be used to determine the intersection of the vector with the closed polyline boundary (providing the boundary is composed of a single polyline and not the intersection of multiple objects), such intersections are then the line end points. Quote
BIGAL Posted March 22, 2013 Posted March 22, 2013 Maybe also hatch boundary.lsp it creates a new boundary of an existing hatch pattern as a pline. Then use this with ssget "WP" Google HATCHB.LSP ver 2.1 Recreates hatch boundary by selecting a hatch www.jtbworld.com By Jimmy Bergmark Quote
spiker7221 Posted March 22, 2013 Author Posted March 22, 2013 Thanks for the help Lee. I undestand and will give it a try. I'm having trouble with another chunk of code. It has been awhile since I've LISP coded...it's still coming back to me... Can you take alook at the below portion and tell me why it's crashing. The IF/REPEAT section has worked flawlessly in other routines of mine, but for some reason this bombs. Do I have the CNT reset in the wrong place? I have some other SETQs calculating the midpt of the line, the text ins pt, and text rotation... xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx .... (setq txt "Hello") (prompt "\nPick lines...") (setq ENT (ssget '((0 . "LINE")))) (if (not (null ENT)) (progn (setq LEN (sslength ENT)) (repeat LEN (setq ent1 (ssname ENT CNT) lp1 (cdr (assoc 10 (entget ent1))) lp2 (cdr (assoc 11 (entget ent1))) ;...text ins pt and rotation calculated here... );_setq (command "text" "j" "mc "" "6" "" txt "") (setq CNT (1+ CNT)) ); end repeat ); end progn ); end if xxxxxxxxxxxxxxxxxxxxxxxxxxxx Quote
MSasu Posted March 22, 2013 Posted March 22, 2013 What do you want to achieve with that code? Please pay attention that line below isn't have the quotes balanced: (command "text" "j" "mc "" "6" "" txt "") Also, you missed to initiate the counter and to specify the angle for text (if its height isn't imposed by text style): (setq txt "Hello") (prompt "\nPick lines...") (setq ENT (ssget '((0 . "LINE"))) [color=red]CNT 0[/color]) (if (not (null ENT)) (progn (setq LEN (sslength ENT)) (repeat LEN (setq ent1 (ssname ENT CNT) lp1 (cdr (assoc 10 (entget ent1))) lp2 (cdr (assoc 11 (entget ent1))) );_setq [color=red](command "text" "j" "mc" lp1 6 0.0 txt)[/color] ;??? (setq CNT (1+ CNT)) ); end repeat ); end progn ); end if Quote
SLW210 Posted March 22, 2013 Posted March 22, 2013 spiker7221, Please read the CODE POSTING GUIDELINES and edit your Code to include Code Tags. Quote
spiker7221 Posted March 22, 2013 Author Posted March 22, 2013 Good afternoon MSasu, Here's a bigger portion of my code... (prompt "\nPick rafters...") (setq ENT (ssget '((0 . "LINE"))) CNT 0) (if (not (null ENT)) (progn (setq LEN (sslength ENT)) (repeat LEN (setq ent1 (ssname ENT CNT) jspi (cdr (assoc 10 (entget ent1))) jepi (cdr (assoc 11 (entget ent1))) jspx (car jspi) jspy (cadr jspi) jsp2 (list jspx jspy) jepx (car jepi) jepy (cadr jepi) jep2 (list jepx jepy) pt1a jsp2 pt2a jep2 aten (angle pt1a pt2a) mpt1 (/ (distance pt1a pt2a) 2.0) mpt (polar pt1a aten mpt1) tenl (+ (distance pt1a pt2a) 4.0) tenl2 (/ tenl 12.0) tenf (fix (+ tenl2 0.501)) txti (rtos tenda 2 0) txt (strcat txti "'") );_setq (command "text" "j" txtjust petxt "6" txtro txt "") (setq CNT (1+ CNT)) ); end repeat ); end progn ); end if Quote
spiker7221 Posted March 22, 2013 Author Posted March 22, 2013 Hey MSasu, My end goal is to select a group of lines and add text to each one (at the Midpt) with the length value as text. Mike Quote
MSasu Posted March 22, 2013 Posted March 22, 2013 The variables in red were not initialized or were missing from the excerpt; also the last in command call isn't required. ... txti (rtos [color=red]tenda[/color] 2 0) txt (strcat txti "'") );_setq (command "text" "j" [color=red]txtjust petxt[/color] "6" [color=red]txtro[/color] txt [s]""[/s]) ... Quote
MSasu Posted March 22, 2013 Posted March 22, 2013 My end goal is to select a group of lines and add text to each one (at the Midpt) with the length value as text. Then, use this to get started: (prompt "\nPick rafters...") (if (setq ENT (ssget '((0 . "LINE")))) (progn (setq CNT 0) (repeat (sslength ENT) (setq ent1 (ssname ENT CNT) jspi (cdr (assoc 10 (entget ent1))) jepi (cdr (assoc 11 (entget ent1))) jmpi (list (/ (+ (car jspi) (car jepi)) 2.0) (/ (+ (cadr jspi) (cadr jepi)) 2.0))) (command "_TEXT" "_J" "_MC" "_non" jmpi 6.0 0.0 (rtos (distance jspi jepi) 2 0)) (setq CNT (1+ CNT)) ) ) ) Quote
spiker7221 Posted March 22, 2013 Author Posted March 22, 2013 Thanks Mircea, Am out the door for the weekend,but will test next week and let you know. Appreciate all your expertise. Mike Quote
BIGAL Posted March 23, 2013 Posted March 23, 2013 Here is a totally alternative way to do it, I posted here under "chevron" islands, a similar problem have a pline shape and want to draw lines over it trimming to edge. Simply it uses two pick points outside shape nominate spacing and draw first line then copies correct amount and trims all lines in one go using EXTRIM no complicated code. As you have 2 pts you can make a selection set using the "F" option automatically then lable each line. Will try to find post. http://www.cadtutor.net/forum/showthread.php?59026-Road-Hatching&highlight=chevron (setq ss (ssget "F" (list pt1 pt2)(list (cons 8 "mylayer")))) then just do lable for each one 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.