hildevasco_br Posted March 19 Posted March 19 Hello I need a routine that allows me to eliminate points from a polyline based on a deflection value or inversion of the direction of the vertices in order to correct its geometry. I am attaching the code that I generated using some existing routines and also a dwg with the incorrect geometry and how it should look after correction. Thanks to anyone who can help errogeomlw.dwg corrgeomlw.lsp Quote
LanloyLisp Posted March 19 Posted March 19 Hi hildevasco_br. Dos sub functions are missing from your lsp routine. Try to locate them. Quote
pkenewell Posted March 19 Posted March 19 (edited) Nevermind - previous comments stricken. Edited March 19 by pkenewell Quote
hildevasco_br Posted March 19 Author Posted March 19 Hello The "dos_" functions belong to the package DOSLIB.ARX available for download on the page: https://wiki.mcneel.com/doslib/home Quote
GLAVCVS Posted March 19 Posted March 19 (edited) Hi HildeVasco. After reading Pkenewell, I don't know if I missed something important in the conversation. Regarding your question, I understand that you need to simplify the geometry of polylines that have too many points. I did something for this years ago. The algorithm is simple: it analyzes the distance from each point to the line between the previous and subsequent points. I set a default value of 1 centimeter, but you can change it at the beginning of the command execution. The code is simple and depends entirely on itself. It works very well. I think it will be useful for you. ;******************* G L A V C V S ******************* ;********************* F E C I T ********************* (defun c:simplificaLWPs (/ toler regen_subNorma cj n) (defun regen_subNorma (ent toler / lstent lstpts pto_ortog saca_list10ptos supripuntos) (defun supripuntos (lstpts / pt1 pt2 pt3 n lst_pts ptort) (setq pt1 (cdr (nth 0 lstpts)) pt2 (cdr (nth 1 lstpts)) n 2 lst_pts (append lst_pts (list (nth 0 lstpts))) ) (while (setq pt3 (nth n lstpts)) (setq pt3 (cdr pt3) ptort (pto_ortog pt1 pt3 pt2 nil) ) (if (or (and ptort (> (distance ptort pt2) toler) ) (and (not ptort) (> (distance pt2 pt1) toler) (> (distance pt2 pt3) toler) ) ) (setq lst_pts (append lst_pts (list (cons 10 pt2))) pt1 pt2 pt2 pt3 n (+ n 1) ) (setq pt2 pt3 n (+ n 1) ) ) ) (append lst_pts (list (cons 10 pt2))) ) (defun pto_ortog (ptvec1 ptvec2 ptbas infin / ang pt) (setq ang (+ (angle ptvec1 ptvec2) (/ pi 2))) (if infin (setq pt (inters ptvec1 ptvec2 ptbas (polar ptbas ang 30000) nil) ) (if (not (setq pt (inters ptvec1 ptvec2 ptbas (polar ptbas ang 30000)) ) ) (setq pt (inters ptvec1 ptvec2 ptbas (polar ptbas (+ ang pi) 30000)) ) pt ) ) ) (setq lstent (entget ent) ) (setq lstpts (vl-remove-if-not '(lambda (x) (= (car x) 10)) lstent)) (setq lstpts (supripuntos lstpts)) (setq lstent (reverse (member (assoc 70 lstent) (reverse lstent)))) (entmod (append (subst (cons 90 (length lstpts)) (assoc 90 lstent) lstent) lstpts ) ) ) (if (not (setq toler (getreal "\nTolerancia máxima en metros <0.01>: "))) (setq toler 0.01) ) (if (setq cj (ssget '((0 . "LWP*")))) (while (setq ent (ssname cj (setq n (if n (1+ n) 0 ) ) ) ) (regen_subNorma ent toler) ) ) (princ (strcat "\nSe han procesado " (itoa n) " polilíneas")) (princ) ) Edited March 19 by GLAVCVS Quote
pkenewell Posted March 19 Posted March 19 1 hour ago, GLAVCVS said: After reading Pkenewell, I don't know if I missed something important in the conversation. @GLAVCVS No problem. I pulled my comments because I wasn't sure I understood correctly. Sometimes I'm plagued with speaking before thinking Quote
BIGAL Posted March 19 Posted March 19 Weed.lsp, Pldiet.lsp to mention a couple. Maybe try them. Quote
GLAVCVS Posted March 20 Posted March 20 16 hours ago, pkenewell said: @GLAVCVS No problem. I pulled my comments because I wasn't sure I understood correctly. Sometimes I'm plagued with speaking before thinking ... Quote
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.