All Activity
- Today
-
Optimizing Workflow with Loop Controls and Data Management
mhupp replied to maahee's topic in AutoLISP, Visual LISP & DCL
You can limit what ssget selects by entity, layer, color, size, basically anything in dxf codes. please read up on ssget This means you could just make a dragged selection negating having to check if its already selected. also @Steven P already said "ssadd does a check if the entity exists in the set" check the length of SS before and after to see if it was already in the list. also also looks like your not using localized variables could be why its taking so long. (defun C:123 ( / ss pick l) (setq ss (ssadd)) (princ "\nSelect Entity: ") (while (setq pick (ssget)) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex pick))) (setq l (sslength ss)) ; Length before adding (setq ss (ssadd ent ss)) ; Try adding entity (if (< l (sslength ss)) ; If length increased, it was added (princ "\nAdded to selection set") (princ "\nAlready in selection set") ) ) (princ (strcat "\n" (itoa (sslength ss)) " Entities now in Selection SS")) ) ; rest of code goes here (princ) ) (defun C:bm ( / ss ent) (while (setq SS (ssget (ssget "_+.:E:S"))) ;exits if selection isn't made (setq ent (ssname ss 0)) ;CODE ) ) -
Is it possible to import surface styles from my template using lisp? I asked Claude and the lisp provided inserts all object styles. ;;-------------------------=={ Import Alignment Styles }==---------------;; ;; ;; ;; Imports Alignment Styles from Power Generation template ;; ;; Uses INSERT method to import block with embedded styles ;; ;; ;; ;;----------------------------------------------------------------------;; (defun C:PG-INS-ALIGN ( / template_dwg curecho curlayer block_name *error*) ;; Error handler (defun *error* (msg) (if curecho (setvar "CMDECHO" curecho)) (if curlayer (setvar "CLAYER" curlayer)) (if (not (member msg '("Function cancelled" "quit / exit abort"))) (princ (strcat "\nError: " msg)) ) (princ) ) ;; Save current settings (setq curecho (getvar "CMDECHO")) (setq curlayer (getvar "CLAYER")) (setvar "CMDECHO" 0) ;; Set template path and block name (setq template_dwg "C:/WSB-DT/Autodesk/Power Generation/Templates/Utility Scale Solar/RENEWABLES-CT-DESIGN.dwt") (setq block_name "TPLT-Alignment-Styles") ;; Check if template file exists (if (findfile template_dwg) (progn (princ "\n----------\nImporting Alignment Styles...") ;; Set layer to 0 (setvar "CLAYER" "0") ;; Insert block from template ;; Format: blockname=filepath (command "_.INSERT" (strcat block_name "=" template_dwg) "0,0,0" ; Insertion point "" ; X scale (default) "" ; Y scale (default) "") ; Rotation (default) ;; Check if insert was successful (if (entlast) (progn ;; Explode the inserted block (command "_.EXPLODE" (entlast)) ;; Purge the block definition (command "._-PURGE" "_B" block_name "_N") ;; Run audit to verify drawing integrity (command "._AUDIT" "_Y") (princ "\n----------\nPower Generation Alignment Styles Have Been Imported!") ) (progn (princ "\n----------\nERROR: Block insertion failed!") (princ (strcat "\nBlock '" block_name "' not found in template")) (princ "\n----------") ) ) ;; Restore settings (setvar "CLAYER" curlayer) (setvar "CMDECHO" curecho) ) (progn ;; Template file not found (setvar "CMDECHO" curecho) (princ "\n----------\nERROR: Template file not found!") (princ (strcat "\nLooking for: " template_dwg)) (princ "\nPlease verify the path is correct") (princ "\n----------") ) ) (princ) ) ;;----------------------------------------------------------------------;; ;; Load Confirmation ;; ;;----------------------------------------------------------------------;; (princ "\n----------") (princ "\nAlignment Style Import Command Loaded:") (princ "\n PG-INS-ALIGN - Import Alignment Styles") (princ "\n") (princ "\nNote: Template must contain a block named 'TPLT-Alignment-Styles'") (princ "\n with embedded alignment style definitions") (princ "\n----------") (princ)
-
david.o joined the community
-
Tamsan joined the community
-
@Marko Ribar has a Travelling Salesman here at CADTutor. TSP.ZIP (Travelling Salesman Problem) - AutoLISP - Programs and Scripts - AutoCAD Forums I was just thinking of the relationship of this to the Travelling Salesman. One of the examples I ran across was similar to @GLAVCVS recess example, as well as the problem of a river that splits around an island or branches ( even a road, ROW, etc.). Even GIS tools need pre and post work and have conditions... Polygon To Centerline (Topographic Production)—ArcGIS Pro | Documentation I think I see why my daughters coworkers use CAD to do the center lines, I am guessing as haven't heard back on details, but I wouldn't be surprised if they used Gian's LISP or similar or just do manually like lrm's demonstration. I also saw an example of that on Bentley MicroStation forums. You may have seen a recurring tool on the GIS forums, etc. called v.centerline. v.centerline - GRASS GIS manual -A link to the source code is at the bottom.
-
Scott, This works with one problem. I hope you can fix it. The leader line becomes to long when selecting the dimension to relocate. If it could stayat the original length, this would be awesome. Thank you for your efforts.
-
Everything SLW210 has researched is very interesting. I had no idea this had been such a thoroughly discussed topic — and with such limited success. I guess that makes it even more interesting. In my opinion, it is possible to obtain a center polyline that is equidistant from both edges. But two conditions must be met: 1. The user must ensure that the geometry of both edges is correct: they must be 2D polylines with no repeated points and no geometric inconsistencies of any kind. And, in principle, to avoid extending the search for a solution, these polylines should not contain arcs. 2. One must accept that any edge containing “recesses” (“recodos”) must be handled using auxiliary axes. What is a recess? It is a geometric setback, in any direction, along one of the edges. For example: if you advance segment by segment along an edge (in either direction), the start of a recess would be defined as any vertex from which the shortest distance to the opposite edge forces the projection to intersect its own edge. My conclusion: for edges without recesses, I believe it is possible to find an equidistant centerline or axis. And for edges with recesses, although considerably more code will be needed, they should be solvable using auxiliary axes. I hope to have code soon that supports all of this.
-
I think ronjonp posted something that if you clicked two points on a polyline it would find the shortest path. (traveling salesman) The method I was working on but haven't finished. two open polylines find start and end points of each test how they are oriented and revers one to use to make a closed polyline find the longest distance between the two original polyline divide that by like 500 and offset in using entlast and eventually will end (cant offset anymore) find the polyline with the lowest area but still has the same amount of vertex as the original boundary. using that smaller boundary to draw vector lines between smallest and original boundary. (where im at now) take all other polylines inside smallest and add them to a point list. remove any points that are Collinear with any of the drawn vector lines. this should leave only the points on the center line. starting at one end need to start group points that are Collinear to each other. of those points entmake a line on the farthest distance. these lines are incomplete segments or might not be touching and will need to be extended to each other or the vector lines or both. problem i am finding/trying to solve what slw210 pointed out about if two segments are close to being parallel points wont be found. need three points to calculate collinear working over a group of points to split out each segment.
-
I just use the QGIS Import for drawings from AutoCAD and I get the layers. I think for surfaces, QGIS needs DEM, IIRC _SurfaceExportToDem is in Civil 3D. Maybe in QGIS Import the SHP or just the .dwg and Go to "Layer" then "Add Layer" then "Add Vector Layer". My QGIS is at home, so I think those steps are close.
-
The "removeDuplicates" function is missing.
-
Aftertouch started following Export layers with objectdata to GIS format
-
Hi all, I get a DWG with multiple layers with lines and such. Now... each line has Object Data linked to it. I need to make a export to GIS, where each layer is its own layer in QGIS. When i make a export to SHP or GML, and load it in QGIS, all layer informatie is gone and is put on only GIS layer. What is the most effective way to export AutoCAD layers to GIS layers?
-
I have been trying to explain the issues to the OP to no avail. From what I gather from my daughter, her coworker does the centerlines in CAD not ArcGIS, then imports them. From what I gather, CAD is better for tweaking a more accurate line manually after running a LISP or other program. Which is apparently what some if not most of the surveyors, geologist, map/civil, etc. are doing no matter the GIS software or CAD software. Getting it close with a tool then tweaking it if needed, or probably if just a one time deal completely manually. I have a couple of new LISPs, I left one of them to draw a different centerline depending on which polyline is picked first, between the two centerlines, one goes close to perfect through the right curves, the other close to perfect through the left curves on the OPs AxisExample.dwg. As I posted, a Voronoi is what most of the tools use, apparently they can get off center as well, but generally work the best. The other option is to go LRM's method or along the lines of Jeffery P. Sanders rolling ball, but the rolling ball can take a while it seems to if looking for accuracy. Daniel's Python method would probably be the best IMO. I still plan on seeing QGIS results when I get the time.
-
Does it not create a polyline for you? I did post it without the 'animation' if that is what you mean.
-
Is it possible that your attached code is incomplete?
-
I copied another function of dijkstra's algorithm to find the shortest path. It might need a lot of optimization, but just as a proof of concept. centerline voronoi dijkstra.lsp
-
ivv joined the community
-
Using a voronoi diagram (code by ymg, ElpanovEvgeniy and Marko Ribar) You can get some very good reference points. Just have to find a way to get rid of all the 'branches' and then take al the midpoints of every line to get a good centerline. centerline-voronoi.lsp
-
Optimizing Workflow with Loop Controls and Data Management
maahee replied to maahee's topic in AutoLISP, Visual LISP & DCL
(defun C:123 () (setq ss (ssadd)) (setq i 0) (while (setq m (ssget)) ; selected group of line one by one or in group large scale (repeat (sslength m) (setq n (ssname m i)) (if (not (ssmemb n ss)) (progn (ssadd n ss) ;;;;;code ) ;progn (progn (princ) (print "/nduplicate selected line:") ) ;progn ) ;if (setq i (1+ i)) ) ;Repeat (setq i 0) ) ;while loop ) ;defun ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;case 2 ;;;;;Press the Enter key once to continue the loop, and press it twice to exit. (defun C:bm () (setq flag T) (while flag (setq obj (ssget "_:S")) (cond (obj ;CODE ) ;ar (t (princ "\nNo selection made.") (initget "X") (setq bm (strcase (getstring "\nEnter 'X' to exit or press Enter to continue [X]: "))) (if (= bm "X") (setq flag nil) ; Exit the loop if user types 'x' (princ "\nInvalid input. Please try again.") ) ;if ); seo cond ) );WHILE ) @BIGAL Test Lisp for reference. The selection set gradually increases, which takes a long time when it is large. -
Something is missing here, in my code it was the call to the Radio button DCL (if (= but nil) (setq but 1)) (cond ((= counter 1) (dotl)) ....... You only set counter to 2 ? You could do a "enter number 1-5 or press enter" Enter will add 1 to counter value. Need to wrap in a while to do this.
-
dvittitoe joined the community
-
mminh joined the community
- Yesterday
-
(defun c:dodimcorner-while (/ *error* ent obj entg dimsc but counter) (defun *error* ( msg ) (setvar 'cmdecho 0) ;; 5.28.24 (vla-endundomark (vla-get-activedocument (vlax-get-acad-object))) (if msg (prompt (strcat "\n" msg))) (setvar 'cmdecho 1) (princ) ) (defun dotl (/) (setq tpos (mapcar '+ (cdr (assoc 13 entg)) (list 0 dimsc 0.0))) (vlax-put obj 'TextMovement 1) (vlax-put obj 'TextPosition tpos) ) (defun dotr (/) (setq tpos (mapcar '+ (cdr (assoc 14 entg)) (list 0.5 dimsc 0.0))) (vlax-put obj 'TextMovement 1) (vlax-put obj 'TextPosition tpos) ) (defun dobl (/) (setq tpos (mapcar '+ (cdr (assoc 13 entg)) (list 0.0 (- dimsc) 0.0))) (vlax-put obj 'TextMovement 1) (vlax-put obj 'TextPosition tpos) ) (defun dobr (/) (setq tpos (mapcar '+ (cdr (assoc 14 entg)) (list 0.0 (- dimsc) 0.0))) (vlax-put obj 'TextMovement 1) (vlax-put obj 'TextPosition tpos) ) (setvar 'cmdecho 0) (setq counter 2) (while (setq ent (car (entsel "\nPick a dim "))) (setq entg (entget ent)) (setq obj (vlax-ename->vla-object ent)) (setq dimsc (vlax-get obj 'scalefactor)) (if (= but nil) (setq but 1)) (cond ((= counter 1) (dotl)) ((= counter 2) (dotr)) ((= counter 3) (dobl)) ((= counter 4) (dobr)) ) (setq counter (+ counter 1)) (if (= counter 5) (setq counter 1)) ) (setvar 'cmdecho 1) (*error* nil) (princ) ) ;;; UPDATE TO INCLUDE RESET ;; (defun c:dtf (/ *error* ent obj entg dimsc but counter) (princ "\n Move DIM Text to Another Location..") ;; https://www.cadtutor.net/forum/topic/97280-toggle-dimension-lisp/#findComment-666274 (defun *error* ( msg ) (setvar 'cmdecho 0) ;; 5.28.24 (vla-endundomark (vla-get-activedocument (vlax-get-acad-object))) (if msg (prompt (strcat "\n" msg))) (setvar 'cmdecho 1) (princ) ) (defun dotx (/) (princ "\n ** Reset **..") (command "dim" "hometext" "_L" "") (command) (command) ;; resets 'dim ) (defun dotl (/) (setq tpos (mapcar '+ (cdr (assoc 13 entg)) (list 0 dimsc 0.0))) (vlax-put obj 'TextMovement 1) (vlax-put obj 'TextPosition tpos) ) (defun dotr (/) (setq tpos (mapcar '+ (cdr (assoc 14 entg)) (list 0.5 dimsc 0.0))) (vlax-put obj 'TextMovement 1) (vlax-put obj 'TextPosition tpos) ) (defun dobl (/) (setq tpos (mapcar '+ (cdr (assoc 13 entg)) (list 0.0 (- dimsc) 0.0))) (vlax-put obj 'TextMovement 1) (vlax-put obj 'TextPosition tpos) ) (defun dobr (/) (setq tpos (mapcar '+ (cdr (assoc 14 entg)) (list 0.0 (- dimsc) 0.0))) (vlax-put obj 'TextMovement 1) (vlax-put obj 'TextPosition tpos) ) (setvar 'cmdecho 0) (setq counter 2) (while (setq ent (car (entsel "\n Pick DIM: "))) (setq entg (entget ent)) (setq obj (vlax-ename->vla-object ent)) (setq dimsc (vlax-get obj 'scalefactor)) (if (= but nil) (setq but 1)) (cond ((= counter 1) (dotl)) ((= counter 2) (dotr)) ((= counter 3) (dobl)) ((= counter 4) (dobr)) ((= counter 5) (dotx)) ) (setq counter (+ counter 1)) (if (= counter 6) (setq counter 1)) ) (setvar 'cmdecho 1) (*error* nil) (princ) ) try this.. update
-
Optimizing Workflow with Loop Controls and Data Management
BIGAL replied to maahee's topic in AutoLISP, Visual LISP & DCL
Like others I really don't understand what your trying to do. You talk about large data sets but what are they and what exactly are you trying to do ? I use a group lists function to look at groups of common item where say 1st item in a sub list is the same, speeds up searches. -
CMAN joined the community
-
Optimizing Workflow with Loop Controls and Data Management
mhupp replied to maahee's topic in AutoLISP, Visual LISP & DCL
Have a progress output to the bottom left for long process is always a good idea because people will cancel commands that they think are hung. https://www.cadtutor.net/forum/topic/75702-all-objects-inside-this-selection-want-to-send-layer-0/#findComment-598604 in the update loop if user hits esc exit lisp -
Optimizing Workflow with Loop Controls and Data Management
Steven P replied to maahee's topic in AutoLISP, Visual LISP & DCL
Case 2: This nicest user friendly way I found.. is not the nicest user friendly way in programming - involves grread which the help suggests is rarely needed and for advanced users.... grread if the input is keyboard or mouse input. If keyboard check if it is enter, X, space or escape (enter, space, escape got to use character codes) else ignore text inputs. If mouse input check if they have selected an object or just clicking empty space However the help suggests doing this in other ways. For both cases, and MHUPPs question what is the goal you are wanting to achieve. -
George P. Burdell joined the community
-
Steven P started following Optimizing Workflow with Loop Controls and Data Management
-
Optimizing Workflow with Loop Controls and Data Management
Steven P replied to maahee's topic in AutoLISP, Visual LISP & DCL
Case 1: ssadd does a check if the entity exists in the set, you can change CASE 1 (setq ss (ssadd)) (if (not (ssmemb n ss)) (ssadd n ss) ;code );if to CASE 1 (ssadd n ss) ;code Often in code optimisation is rarely a single line that makes a difference... unless you are doing thousands of calculations, so here taking out an if statement won't do a lot. Most likely you have a loop within a loop that slows things - might be more efficient to look back at how you are selecting the entities and processing them before adding to the selection set. However don't just accept that, if you code will work without the line take out your if statement, and ssadd and you shouldn't really notice a big difference in speed -
Danielm103 started following Hybrid parallel
-
Apparently, it’s a difficult task, people write papers on them https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8625416
-
Optimizing Workflow with Loop Controls and Data Management
mhupp replied to maahee's topic in AutoLISP, Visual LISP & DCL
I understand what your asking for in case1 case2. I am asking is why your using them. might be a better optimization in how your selecting things. just asking for a higher level of what your trying to do. -
Thank you for your time. The inside stringer is set to code, because we do not "roll" our stringer plates, the outside plates are different than the inside plates, this forces the plates to form a spiral. Really more of a polygon shape with a lot of edges, the selected objects below are for the outside stringer, while they start off in the same position, they move further apart each step, the amount is determined by the diameters. While the math for solving how much the difference is per step isn't very complicated, but it can be very time consuming. All of my searching leads me to believe that a path array will never be the answer, at least for the outside.
-
okan joined the community
-
Speaking of @marko_ribar here is some of his work at the SWAMP. To AutoCAD yours are complicated, if you would pay attention to what's been posted they all get off center in pretty much the same areas, sharp curves that get very wide and very narrow. The inside is shorter than the outside and the reference points differ in number. I posted links to Civil/GIS forums where lots of different software struggle with this. You'll probably have to be satisfied with Gian's solution. If I have time I "might" work on a [send points to Excel/CSV and bring them back in solution], though IMO, I like the QGIS solution or Python might be a way to go for more accuracy. What type of work are you doing? What you have posted looks to be Civil and/or GIS work. Why don't you have the proper programs for this type of work?
