Alexv Posted October 23, 2021 Share Posted October 23, 2021 Hi everyone, I hope y'all are doing well. I'm having issue with my lisp script. I wrote a lisp script that select lines, polylines and 3Dpolylines in certain layers, the script loaded in successfully in Civil 3D but when I try to run the command CQSEL1, nothing happens. Please see attached script. (defun C:CQSEl1 ( / sel1) (setq sel1 (ssget "_X" '((8 . "FNCE,GRADE") (0 . "Line,polyline,3Dpolyline")))) (princ) ) I'm using a few different types of lines in the file, Autocad Line, polyline (Pline) and 3D polyline (3dPoly) in 2 different layers, FNCE and GRADE. I'm hoping to create a lisp scrip that automatically selects the lines in these layers - and then add them to the Surface Breaklines Definition so I can build a surface. The template already has a surface created called "Surface1". All I need is to add the lines to to Breakline definition. I may have gotten the syntax for 3Dpolyline wrong? Could someone please advise. Thanks! I think it's much faster if I draw all my lines in certain layers (FNCE and GRADE) and then run lisp to add the lines to the Surface1's Breaklines definition. So I don't have to manually keep selecting the lines and adding them to the Breaklines definition all the time as I keep adding in new lines. Please see attached .dwg file. I tried to use the Action Macro to record the steps of me selecting the lines using Quick-Select but that didn't work because the Action Macro doesn't record the mouse right clicking and adding the lines to the Surface BreakLine definition. Anyway to work around this issue? Thanks again for this wonderful community and have a good day. Example_Drawing1.dwg Quote Link to comment Share on other sites More sharing options...
mhupp Posted October 23, 2021 Share Posted October 23, 2021 Your lisp only builds the selection set you then have to select it. this should be what your looking for. (defun C:CQSEl1 (/ sel1) (setq sel1 (ssget "_X" '((8 . "FNCE,GRADE") (0 . "Line,polyline,3Dpolyline")))) (sssetfirst nil sel1) (princ) ) 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 23, 2021 Share Posted October 23, 2021 Try "*line" will find all line types that have "line" as part of object type. 1 Quote Link to comment Share on other sites More sharing options...
Alexv Posted October 23, 2021 Author Share Posted October 23, 2021 (edited) @mhupp Thanks for the reply. Yes, the script is now working after adding in (sssetfirst nil sel1). Thank you!! @BIGAL I tried just having the 'Line' in the code but it only selected the Autocad Lines and left out the 3dpolylines and polylines. So I had to use 'Line,polyline,lwpolyline' in the code for it to select all the different line types. I may have not written the code properly for the 'Line' alone to work. (setq sel1 (ssget "_X" '((8 . "FNCE,GRADE") (0 . "Line,polyline,lwpolyline")))) Now, I'm trying to write the code to add the selected lines to Surface1's breakline definitions. But I can't find the code syntax for this function anywhere. the command line doesn't show the command for adding stuff to the Surface's breakline, so I don't know where to begin on calling those commands. Thanks heaps everyone for your time Example_Drawing1.dwg Edited October 23, 2021 by Alexv Quote Link to comment Share on other sites More sharing options...
Alexv Posted October 23, 2021 Author Share Posted October 23, 2021 Hi all, just keeping y'all updated. I have found the command to add the lines to the Surface Breakline definition. It's AddSurfaceBreaklines. I've got the stuff to work like I wanted to. Thankyou everyone for all your guidance, help and time. I greatly appreciate everything that y'all have done for me. Have a good day Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 24, 2021 Share Posted October 24, 2021 "*LINE" = "Line,polyline,lwpolyline" 1 Quote Link to comment Share on other sites More sharing options...
Alexv Posted October 25, 2021 Author Share Posted October 25, 2021 (edited) @BIGAL Oh I see, thanks for correcting me. I'll try that out!. Another question relating this issue again. Is it possible to select only specific type of lines in certain layers? For example, I want to select Lines, polylines and 3D polylines in the FNCE and GRADE layers. And I also want to select *only* polylines in the CONC layer even though there may be other line types in the CONC layer. Can it be done in the same argument? I tried to modify my code but I got an error saying 'too many arguments. Please see my code, any advice on correcting it is great appreciated as always (defun C:Cexclue2 ( / sel1 sel2) (setq sel1 (ssget "_X" '((8 . "FNCE,GRADE") (0 . "Line,polyline,lwpolyline")))) (setq sel2 (ssget "_X" '((8 . "CONC") (0 . "polyline")))) (sssetfirst nil sel1 sel2) (princ) ) Edited October 25, 2021 by Alexv Quote Link to comment Share on other sites More sharing options...
mhupp Posted October 25, 2021 Share Posted October 25, 2021 (edited) Two main ways to do this. (defun C:Cexclue2 (/ sel1 sel2) (setq sel1 (ssget "_X" '((8 . "FNCE,GRADE") (0 . "Line,polyline,lwpolyline")))) (setq sel2 (ssget "_X" '((8 . "CONC") (0 . "polyline")))) (foreach ent (mapcar 'cadr (ssnamex sel2)) (ssadd ent sel1) ) (sssetfirst nil sel1) (princ) ) If you using ssget with out "_X" you will need to use the following (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) This selects each selections set and uses the ssget previously selected to create a new selection set. (defun C:Cexclue2 (/ sel1 sel2) (setq sel1 (ssget "_X" '((8 . "FNCE,GRADE") (0 . "Line,polyline,lwpolyline")))) (setq sel2 (ssget "_X" '((8 . "CONC") (0 . "polyline")))) (command "_.Select" sel1 sel2) (setq sel1 (ssget "_P")) (sssetfirst nil sel1) (princ) ) I try and stay away from (command usage because i feel it has a greater potential to cause errors. Edited October 25, 2021 by mhupp 1 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 26, 2021 Share Posted October 26, 2021 As your using CIV3D have you thought about using the codes in a better way say making any layer set to be a breakline, with a common prefix or suffix, a code will have a point but also the function of being a string, so maybe add a suffix to the layer EBL-BR, CL-BR, EBR-BR and so on. Then only need a few layers as they will always only have linetypes of any type. 1 Quote Link to comment Share on other sites More sharing options...
Alexv Posted October 26, 2021 Author Share Posted October 26, 2021 @mhupp Thanks heaps! Both set of codes are working great. Though I'm using the second set of codes since I could understand those code syntax more than the first set. I appreciate your time and for providing me with the 2 examples of codes doing the same thing. @BIGAL I'm not quite following what you meant. Could you please elaborate 'making a layer set to be breakline' and a 'code function of being a string'? Do you mean, create a different layer (with suffix) for each different type of line? From my understanding, let's say, in my FNCE layer, I have 2 different sets of lines, one (2dpolyline) for 2D boundary definition which won't have elevation data and would only be used for defining the fencing boundary and create a void (trim) in the surface and won't be included in the surface creation. And another type of line (3dpolyline) which has elevation data and will be used for surface creation. I have been using the quick-selection command to manually select each type of line for each layer and adding them to the surface's breakline definition - which can be quite time consuming if there are dozens of layers to do. Hence I wanted a lisp that could do all the selections in one go and be more efficient. Thanks everyone and have a good week Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 27, 2021 Share Posted October 27, 2021 (edited) Are you starting with a survey instrument file or a csv or getting the dwg from someone else ? Re fnce, fnce-3d the 3d implies it is a breakline. So can do *3d for breaklines, would be pretty easy to do find 3dpolylines add a new layer and change object layer. Edited October 27, 2021 by BIGAL 1 Quote Link to comment Share on other sites More sharing options...
Alexv Posted November 6, 2021 Author Share Posted November 6, 2021 On 10/27/2021 at 3:10 PM, BIGAL said: Are you starting with a survey instrument file or a csv or getting the dwg from someone else ? Re fnce, fnce-3d the 3d implies it is a breakline. So can do *3d for breaklines, would be pretty easy to do find 3dpolylines add a new layer and change object layer. Hi Bigal, sorry for the late reply. Not sure why I didn't get any notification alert. I see what you meant now. So basically have 2 different layers for the same feature, one as 2D and another as 3D which could be used for Breakline to create the surface. I'm using a dwg from someone else. Thanks heaps for the clarification. Quote Link to comment Share on other sites More sharing options...
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.