I have a lisp routine I use occasionaly and I want to add a promp to the beginning of it. When I run the code, it just runs. I would like to add a conformation to it. I currently put my LISP routines in a tool pallete and a prompt would prevent it from running if I accidently clicked it.
The code is one for Civil3D that converts all survey figures to polylines. Very useful. When I run the command I would like a prompt that said "Are you sure you want to run this command? Steamroller will convert ALL survey figures to 2D polylines and will segment all arcs contained within survey figures" Then a Yes/No which defaults to No. No would exit the command before it ran, Yes would just run the command.
I have altered some code in my day, just not sure how to add this statement to the beginning.
Here is the code:
(defun C:STEAMROLLER ()
(setvar "CMDECHO" 0)
(setvar "qaflags" 1)
(if (setq C3DOBJ (ssget "X" '((0 . "AECC_SVFIGURE*"))))
(command "explode" C3DOBJ "" "AeccConvert3dPolys" "P" "")
)
(if (setq C3DOBJ (ssget "X" '((0 . "AECC_FEATURE_LINE*"))))
(command "explode" C3DOBJ "" "AeccConvert3dPolys" "P" "")
)
(if (setq C3DOBJ (ssget "X" '((0 . "POLYLINE*"))))
(command "AeccConvert3dPolys" C3DOBJ "")
)
(if (setq C3DOBJ (ssget "X" '((0 . "LWPOLYLINE*"))))
(command "CHANGE" C3DOBJ "" "P" "ELEV" "0" "" "PEDIT" "M" "P" "" "L" "ON" "")
)
(setvar "qaflags" 0)
(setvar "CMDECHO" 1)
)
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
@claimed4all wrote:
I have a lisp routine ... and I want to add a promp to the beginning of it. .... I would like to add a conformation to it. ....
.... When I run the command I would like a prompt that said "Are you sure you want to run this command? Steamroller will convert ALL survey figures to 2D polylines and will segment all arcs contained within survey figures" Then a Yes/No which defaults to No. No would exit the command before it ran, Yes would just run the command.
....
Here's one way:
(defun C:STEAMROLLER ()
(initget "Yes No")
(if
(=
(getkword "Are you sure you want to run this command? Steamroller will convert ALL survey figures to 2D polylines and will segment all arcs contained within survey figures [Yes/No] <N>: ")
"Yes"
); =
(progn ; 'then'
(setvar "CMDECHO" 0)
... the rest of it ...
(setvar "CMDECHO" 1)
); progn
(prompt "\nOkay then, I won't do it."); 'else'
); if
); defun
Worked like a charm. I will use that as a guide for next time I want to do the same thing. Thank You!
@Kent1Cooper wrote:
@claimed4allwrote:I have a lisp routine ... and I want to add a promp to the beginning of it. .... I would like to add a conformation to it. ....
.... When I run the command I would like a prompt that said "Are you sure you want to run this command? Steamroller will convert ALL survey figures to 2D polylines and will segment all arcs contained within survey figures" Then a Yes/No which defaults to No. No would exit the command before it ran, Yes would just run the command.
....
Here's one way:
(defun C:STEAMROLLER ()
(initget "Yes No")
(if
(=
(getkword "Are you sure you want to run this command? Steamroller will convert ALL survey figures to 2D polylines and will segment all arcs contained within survey figures [Yes/No] <N>: ")
"Yes"
); =
(progn ; 'then'
(setvar "CMDECHO" 0)
... the rest of it ...(setvar "CMDECHO" 1)
); progn
(prompt "\nOkay then, I won't do it."); 'else'
); if
); defun
Hello,
Is it there any way to "bypass"/ignore/filter out Polylines with elevations assigned, so it won't get their elevation "flattened"/changed to 0.00 in the following modified code?
(defun C:STEAMROLLER (/)
(setvar "CMDECHO" 0)
(setvar "qaflags" 1)
(if (setq C3DOBJ1 (ssget "X" '((0 . "AECC_SVFIGURE*"))))
(command "explode" C3DOBJ1 "" "AeccConvert3dPolys" "P" "")
)
(if (setq C3DOBJ2 (ssget "X" '((0 . "POLYLINE*"))))
(command "AeccConvert3dPolys" C3DOBJ2 "")
)
(if (setq C3DOBJ3 (ssget "X" '((0 . "LWPOLYLINE*"))))
(command "CHANGE" C3DOBJ3 "" "P" "ELEV" "0" "" "PEDIT" "M" "P" "" "L" "ON" "")
)
(setvar "qaflags" 0)
(setvar "CMDECHO" 1)
)
You should be able to just remove the CHANGE part that changes the Elevation, and put the selection into the PEDIT part in place of the Previous-selection input. Try changing this:
(command "CHANGE" C3DOBJ3 "" "P" "ELEV" "0" "" "PEDIT" "M" "P" "" "L" "ON" "")
to this [untested]:
(command "PEDIT" "M" C3DOBJ3 "" "L" "ON" "")
S
@Kent1Cooper wrote:You should be able to just remove the CHANGE part that changes the Elevation, and put the selection into the PEDIT part in place of the Previous-selection input. Try changing this:
(command "CHANGE" C3DOBJ3 "" "P" "ELEV" "0" "" "PEDIT" "M" "P" "" "L" "ON" "")
to this [untested]:
(command "PEDIT" "M" C3DOBJ3 "" "L" "ON" "")
Sorry, but I guess I've expressed myself wrong: I would like to just bring to elevation 0.000 all the Survey Figures that was previously exploded and then converted from 3D polyline to LWPOLYLINE, but leaving all other LWPOLYLINEs of drawing that already contains elevation untouched. Your suggestion worked great, but it keeps the elevation for all polylines that was previously converted from Survey Figures.
Just as an example: if I use this LISP in a drawing that contains countour lines as Polylines with elevation, they will be at 0.000 elevation in the end of routine. I would like to keep them with their elevations after running this routine just bringing to 0.000 the Survey Figures that was converted in first selection using (ssget "X" '((0 . "AECC_SVFIGURE*")))) to Polylines.
Thanks!
Pretty sure you can ssget filter elev = 0.0 I am not an expert on filters with conditions it uses a pt (x y 0.0) compare.
If its a LWpolyline assoc 38 is elevation. Now an example where is it.
maybe (setq ss (ssget '((0 . "LWPOLYLINE") (-4 . "=") (38 . 0.0))))
@luiz.toniolo wrote:
.... if I use this LISP in a drawing that contains countour lines as Polylines with elevation, they will be at 0.000 elevation in the end of routine. I would like to keep them with their elevations after running this routine just bringing to 0.000 the Survey Figures that was converted in first selection using (ssget "X" '((0 . "AECC_SVFIGURE*")))) to Polylines.
....
I don't have the "AECCCONVERT3DPOLYS" command in my plain AutoCAD. When you use that on a selection of 3D Polylines, afterwards can you choose an editing command and use Previous to select them for it? If so, it should be an easy adjustment; if not, more complicated.
@Kent1Cooper wrote:
@luiz.toniolo wrote:.... if I use this LISP in a drawing that contains countour lines as Polylines with elevation, they will be at 0.000 elevation in the end of routine. I would like to keep them with their elevations after running this routine just bringing to 0.000 the Survey Figures that was converted in first selection using (ssget "X" '((0 . "AECC_SVFIGURE*")))) to Polylines.
....
I don't have the "AECCCONVERT3DPOLYS" command in my plain AutoCAD. When you use that on a selection of 3D Polylines, afterwards can you choose an editing command and use Previous to select them for it? If so, it should be an easy adjustment; if not, more complicated.
Aftwards I don't use any editing command. Just this sequence:
(if (setq C3DOBJ (ssget "X" '((0 . "AECC_SVFIGURE*"))))
(command "explode" C3DOBJ "" "AeccConvert3dPolys" "P" "")
)
(if (setq C3DOBJ (ssget "X" '((0 . "POLYLINE*"))))
(command "AeccConvert3dPolys" C3DOBJ "")
)
(if (setq C3DOBJ (ssget "X" '((0 . "LWPOLYLINE*"))))
(command "CHANGE" C3DOBJ "" "P" "ELEV" "0" "" "PEDIT" "M" "P" "" "L" "ON" "")
)
I've attached an example/sample dwg file that contais Survey Figures and contour lines as Polylines with elevations. In the end of routine, contours ends at 0.0 elevation aswell. My intention was to filter out any polyline with elevation besides those ones that were converted from Survey Figures using the LISP.
@luiz.toniolo wrote:
..... Aftwards I don't use any editing command. ....
My point in asking the question was not to suggest that you do so, but only to find out whether Previous as a selection option would "see" the same Polylines that were converted by AeccConvert3dPolys. [I suspect not, since they'd be a different entity type than they were, and I assume have different entity names, but I have found in the past that certain kinds of changes do not change the entity name, I think even some that change the entity type.] I can't test that, not having that command.
If Previous selection does find the same ones, you can simply apply the same CHANGE command to change their Elevation, substituting Previous as selection in place of that find-all-LWPolylines (ssget) function.
If it doesn't, I suspect the procedure would need to involve setting the last entity before the AeccConvert3dPolys operation into a variable as a marker, then after the conversion, stepping through finding all objects newer than that marked entity, and putting them into a selection set to CHANGE.
@Kent1Cooper wrote:My point in asking the question was not to suggest that you do so, but only to find out whether Previous as a selection option would "see" the same Polylines that were converted by AeccConvert3dPolys.
For both "last" and "previous" selection options, the same Polylines aren't selected. So you are right, must be changing the entities names while converting from Survey to 3D polyline, then to Polylines. Anyways, thanks for trying to help me mate...
@Kent1Cooper Here is a super dumb and zero skills modification I've made using "ISOLATE" command to get this task done. Not fully automated routine and still needs user input to select polylines on screen and press "enter", but with this I've managed to convert Survey Figures to Polylines, leaving untouched/intact those polylines in drawing whose contains elevations assign to them, as contour polylines for example:
(defun c:STEAMROLLER (/)
(setvar "CMDECHO" 0)
(setvar "qaflags" 1)
(if (setq C3DOBJ1 (ssget "X" '((0 . "AECC_SVFIGURE*"))))
(progn
(command "_.ISOLATEOBJECTS" C3DOBJ1 "")
(command "explode" C3DOBJ1 "" "AeccConvert3dPolys" "P" "")
)
)
(princ "\nSelect objects and press enter: \n")
(if (setq C3DOBJ2 (ssget "_:L" '((0 . "POLYLINE*,LWPOLYLINE*"))))
(command "CHANGE" C3DOBJ2 "" "P" "ELEV" "0" "" "PEDIT" "M" "P" "" "L" "ON" "")
)
(command "_.UNISOLATEOBJECTS")
(setvar "qaflags" 0)
(setvar "CMDECHO" 1)
); defun
(princ)
(c:STEAMROLLER)