All Activity
- Past hour
-
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
- Today
-
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?
-
Optimizing Workflow with Loop Controls and Data Management
maahee replied to maahee's topic in AutoLISP, Visual LISP & DCL
@mhupp Case 1: I want to reduce the time. I use the "not (ssmemb n ss)" function, but it takes a long time when the selection set is large. case 2: Press the Enter key once to continue the loop, and press it twice to exit. ( empty selection set handle) The above two cases do not relate to each other. Please -
mhupp started following Optimizing Workflow with Loop Controls and Data Management
-
Optimizing Workflow with Loop Controls and Data Management
mhupp replied to maahee's topic in AutoLISP, Visual LISP & DCL
I'm not quite sure what your asking to optimize. -
Optimizing Workflow with Loop Controls and Data Management
maahee posted a topic in AutoLISP, Visual LISP & DCL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CASE 1 (setq ss (ssadd)) (if (not (ssmemb n ss)) (ssadd n ss) ;code );if ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CASE 2 (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 ) ) );WHILE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CASE 1: If the dataset is large, it will slow down the process. alternatives or tricks. CASE 2: Press the Enter key once to continue the loop, and press it twice to exit. or Only the letter "x" and empty inputs are acceptable. -
Lee Mac started following Autolisp for batch freezing & Thaw
-
Agree with @mhupp, just set the layer in question to not plot. But don't use the Defpoints layer for this (that is reserved for dimension definition points) - use/create your own non-plotting layer.
-
amndablsn51 joined the community
-
Kiran.k joined the community
-
I assume there are complex cases where determining a centerline that’s perfectly equidistant from both edges can be quite challenging. However, I don’t think the examples we’ve discussed in this thread fall into that category. I guess I can live without a perfectly accurate solution. My question was more of a spontaneous one — I thought it might be feasible to achieve in less demanding cases. In any case, the subject is really interesting and seems to be turning into a bit of a trending topic.
-
If you use a plot lisp can set layers off/frozen do plot then turn back on. If using layouts can set layer frozen in a viewport but see in Model, may be the simplest way.
-
Re draw stairs why the need for a dynamic block ? You can do from first principles by 2 methods work out the rise run etc to meet code. Using a block can place along a line using copy or multiple insert, another way is use array the block single row with multiple columns. When using Array use UCS Object pick the line for the array, then UCS W. NOTE the important part about Rise/Run meeting code.
- Last week
-
mhupp started following Toggle dimension LISP
-
Did this not work? https://www.cadtutor.net/forum/topic/97280-toggle-dimension-lisp/#findComment-666262
-
jrr114 started following Toggle dimension LISP
-
Does anyone have a LISP routine that will toggle dimension text with a leader to different quadrants around the dimension line?
-
Steven P started following Autolisp for batch freezing & Thaw
-
Autolisp for batch freezing & Thaw
Steven P replied to Ikkukp's topic in AutoLISP, Visual LISP & DCL
Can also put these into a routine: (command "-layer" "ON" "ListofLayers, EachLayerSeperated, Withcomma" "") ; Turns layer ON.. try 'OFF' (command "-layer" "FREEZE" "ListofLayers, EachLayerSeperated, Withcomma" "") ; Freezes layer, ty 'Thaw' as well For completion: (command "-layer" "SET" "LayerName" "") ; Sets current layer MHUPPs probably runs faster (like milliseconds) and a nice option to choose the layer, my ideas maybe better if the layer names are set and can be hard coded into the routine... but useless if each drawing / project uses a different name -
mhupp started following Autolisp for batch freezing & Thaw and Moving objects within polyline to different layer
-
Moving objects within polyline to different layer
mhupp replied to Hsanon's topic in AutoLISP, Visual LISP & DCL
They are either on a locked layer. have an error msg saying # number entitys on locked layer can't move. or inside a block or xref. (setq ss (ssget "WP" Co-ord)) ; Select all entities in window polygon (setq lock (ssget "WP:L" Co-ord)) ; Select entities not on locked layers (setq n (- (sslength ss) (sslength lock))) ; Calculate difference (if (> n 0) ; if n is greater than 0 display msg (prompt (strcat "\n" (itoa n) " entities on a locked layer")) ) -
Depends on what you want to do. this will freeze a layer of the entity you select is on. (defun c:FreezeEntity (/ ent layN layO) (while (setq ent (entsel "\nSelect an entity to freeze layer: ")) (setq layN (cdr (assoc 8 (entget (car ent))))) (setq layO (vla-item (vla-get-Layers (vla-get-ActiveDocument (vlax-get-Acad-Object))) layN)) (vla-put-Freeze layO :vlax-true) (prompt (strcat "\nLayer \"" layN "\" has been frozen.")) ) (princ) ) -Edit Why not just have the calculations on defpoints or some other layer that is set not to print. (vla-put-Plottable layo :vlax-false)
