Hello again guys.
I am looking for a way to extract (filter) all polylines, and loop a lisp based on the number that are found within a "W" selection window.
I am frustrated getting "malformed list" or errors, even after defining "n" for repeat.
The code I have so far looks like this:
(defun c:PWW (/ p1 p2 sspw myObj ss)
(setq p1 (getpoint "\nPick first corner: "))
(setq p2 (getcorner p1 "\nSpecify opposite corner: "))
(if
(setq sspw (ssget "W" p1 p2 '((0 . "*POLYLINE")))
)
(repeat n
(command "_.explode" sspw)
(command "_.pedit" "m" sspw "" "Y" "J" "" "")
; (command "_.pedit" "m" sspw "" "w" 0.01 "" )
; (command "_.pedit" "m" sspw "" "w" 0 "" )
)
);end defun
(princ "\nConverted all 2D Polylines.")
(princ)
)
==
Without the (repeat () portion, it was working ok with selection window, however it only would run the commands for a single polyline. What needs to be done without overhauling the code? The lisp has worked on a drawing-wide basis, however needs to run on only on user-windowed polylines since there are other polylines within the drawing which are attached to layouts via viewports. As with my previous post, this has to be done on a multitude of objects, with exception this time of localized areas.
Solved! Go to Solution.
Solved by alanjt_. Go to Solution.
Solved by alanjt_. Go to Solution.
@BlackBox_ wrote:
@Anonymous wrote:... Region will not function on polylines which overlap themselves. I have a lisp routine that will remove the extraneous line, but it only recognizes Polylines, not 2D polylines. The entire process has to be automated down to a single step (minus hatching at the end).
Just saw this... I'm willing to bet that we could do the total process in one step, if you'd be willing to share your code for us to offer refinement(s)?
Here are the three codes which can be used to get the entire process complete, start to near finish.
"TTG" is a series of commands called forth to explode the text, region it out, then union the regions.
"PW_cur" uses the code Alanjt responded with in this post.
"PLVdel" is a lisp located on the forums here, credits are within the lisp to the originator.
After running all three for their various purposes, region and union to the same selection sets used between all, need to be run. The entire process is complete once that is done. The goal now (which in the mean time I will be doing my usual frankenstein-compiling) will be to combine all three into a functional single lisp.
Thank you hundred times over to everyone that has helped get these this far.
@pbejse wrote:
@alanjt_ wrote:Slightly bit more streamlined. Granted, this would still be best to step through the entity data and entmake the LWPolyline.
..... (if (setq _pedit (if (eq (getvar 'PEDITACCEPT) 1) (lambda (ss) (command "_.pedit" "_m" ss "" "_j" "" "")) (lambda (ss) (command "_.pedit" "_m" ss "" "_y" "_j" "" "")) )
Nice idea Alanjt. unusual but clever nonetheless.
Not sure if this will work the same way as your approach.
(if (> (sslength add) 0) (progn (command "_.pedit" "_m" add "") (if (zerop (getvar 'PEDITACCEPT)) (command "_y" "_j" "" "") (command "_j" "" "")) ) )
The reason I wrote it as a subroutine was to check the peditaccept variable before the command is executed. For your method, the routien has to check the variable for each entity, when stepping through the selection set of polylines.
@alanjt_ wrote:The reason I wrote it as a subroutine was to check the peditaccept variable before the command is executed. For your method, the routien has to check the variable for each entity, when stepping through the selection set of polylines.
Of course it will be inefficient to do that, but i was refering to the idea of using a sub instead of re-setting the system varlable in general my friend and not the routine itself.
Cheers
and this (command "_.pedit" "_m" add "")
(if (zerop (getvar 'PEDITACCEPT))
(command "_y" "_j" "" "")
(command "_j" "" ""))
meaning....
(command "_.pedit" "_m" add "")
(if pe
(command "_y" "_j" "" "")
(command "_j" "" "") [or sub in place of the two] )
@pbejse wrote:
@alanjt_ wrote:The reason I wrote it as a subroutine was to check the peditaccept variable before the command is executed. For your method, the routien has to check the variable for each entity, when stepping through the selection set of polylines.Of course it will be inefficient to do that, but i was refering to the idea of using a sub instead of re-setting the system varlable in general my friend and not the routine itself.
Cheers
and this (command "_.pedit" "_m" add "")
(if (zerop (getvar 'PEDITACCEPT))
(command "_y" "_j" "" "")
(command "_j" "" ""))
meaning....
(command "_.pedit" "_m" add "")
(if pe
(command "_y" "_j" "" "")
(command "_j" "" "") [or sub in place of the two] )
Ahh right on. Yeah, I try and avoid resetting of variables if possible. Removes the need for *error* handling and fear of undo not catching every thing. Plus, there's always the chance a user is running a version of autocad that predates the PEDITACCEPT system variable - the other reason I choose to use eq to 1 rather than zerop, regardless of how unlikely that is, given that PEDITACCEPT is pretty old. Man, that was quite the run-on sentence.