All Activity
- Past hour
-
Lisp exportar todas las presentaciones
BIGAL replied to mikarts's topic in AutoLISP, Visual LISP & DCL
You are correct. change the value of presentacion. (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-" presentacion ) (setq num (getint "\nEnter start number ")) (cond ((< num 10)(setq presentacion (Strcat "00" (rtos num 2 0)))) ((< num 100)(setq presentacion (Strcat "0" (rtos num 2 0)))) ((>= num 100)(setq presentacion (rtos num 2 0))) ) (setq num (1+ num)) -
Moving objects within polyline to different layer
BIGAL replied to Hsanon's topic in AutoLISP, Visual LISP & DCL
My $0.05 I use this method in some code, I get all objects inside a poly object, and change layer then do a Layer off, can then do a "Select All" and use the simple chprop command to change layer to Site" then turn layer exist back on. In another program I go a step further and not only change layer name but add "EXIST-" to the layer name and change its color to light grey. As we had in house surveyors made a list of layer names to look for may be useful as it does not rely on a inside outside approach. -
dan20047 started following Viewport Inset Generator
-
Here is my code which draws mspace rectangles for viewport extents. It's missing subroutines prefixed with XYZ, but the main code for the coordinates can be used. ;;; Draw rectangle inside viewport limits (defun c:RTV (/ pt1 pt2 dy dx vcx vcy pt3x pt3y pt4x pt4y) (XYZ-ERROR-INIT (list (list "clayer" (getvar "clayer") "cmdecho" 0) T)) ;do list of variables to be set/reset (if (not XYZ_LAY_VPORT) (setq XYZ_LAY_VPORT (getvar "clayer"))) (if (not (tblsearch "LAYER" XYZ_LAY_VPORT)) (command "-layer" "make" XYZ_LAY_VPORT "color" "7" "" "plot" "no" "") ;make layer if it doesn't exist ) (command "-layer" "thaw" XYZ_LAY_VPORT "on" XYZ_LAY_VPORT "set" XYZ_LAY_VPORT "") ;thaw layer whether it exists or not (if (or (= 1 (caar (Vports))) ;determine if in mspace vport (= 1 (getvar "tilemode"))) (progn (XYZ_rectangle nil (getvar "vsmin") (getvar "vsmax")) (command "scale" (entlast) "" (getvar "viewctr") (/ (getvar "viewsize") (- (cadr (getvar "vsmax")) (cadr (getvar "vsmin")))) ) ) (progn ;if in mspace vport (setq pt1 (cadr (car (vports))) ;vport corners pt2 (caddr (car (vports))) dy (distance pt1 (list (car pt1) (cadr pt2))) ;height of vport dx (distance pt2 (list (car pt1) (cadr pt2))) ;width of vport vcx (car (getvar "viewctr")) ;x pt of vport center vcy (cadr (getvar "viewctr")) ;y pt sclf (/ (getvar "viewsize") dy) ;vport scale factor pt3x (- vcx (* 0.5 dx sclf)) ;points of vport extent pt3y (- vcy (* 0.5 dy sclf)) pt4x (+ vcx (* 0.5 dx sclf)) pt4y (+ vcy (* 0.5 dy sclf)) ) (XYZ_rectangle nil (list pt3x pt3y) (list pt4x pt4y)) ;if not in mspace use virtual viewport limits ) ) (princ "\nPline rectangle drawn to viewport limits") (XYZ-ERROR-RESTORE) )
- Today
-
Viewport Inset Generator
CyberAngel replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
The Architecture system has a mechanism for creating Views, which you can then assign to viewports. I assume (but don't know) that you can show those Views in other viewports, such as the key plan you describe, and label them. All of that would be really handy in my job, but Civil doesn't include that mechanism for some reason. I guess you'd have to create a new object type, View. It would include the name, the bounds, and the UCS for one sheet. You'd have the ability to create a viewport, capture the bounds, and annotate it with the name and the scale. You could also apply one view to another, as with the insets on the key map. To be even more helpful, there'd be a new category in the Prospector so you could manage all those views. And maybe a layer state for the viewports. -
I have a Key Plan Viewport showing the wider site plan and I have multiple viewports showing specific areas of the wider site plan (Insets). Has it been done or attempted to create a lisp that will prompt the user to select the Key Plan Viewport, and then select the other Insets and show the Inset extents on the Key Plan Viewport as Rectangles?+
-
Thonyb started following Batch Visibility Change
-
Hi everyone, My topic may have been addressed already, but I couldn’t find it. Here’s my situation: I have a large number of drawings (around 900), and I need to batch-change the visibility state of a specific dynamic block, similar to this thread: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-edit-visibility-state-of-dynamic-block/td-p/5629689 I know Lee-Mac has several .lsp routines that use ObjectDBX (OBDX). I’m not much of a coder, but I’m hoping someone here could help me put something together (or point me to the right approach). Thanks!
-
Lisp exportar todas las presentaciones
devitg replied to mikarts's topic in AutoLISP, Visual LISP & DCL
@ivaj Hola , ¿que cad tienes ? y si puedes subir el DWG , se puede analizar. -
I tested the code. All the points are equidistant, but there are two long segments where the equidistance is drastically broken. In the last screenshot Dexus attached, you can see approximately where the center line should be in that area. The center line returned by the GLAVCVS code is shown in magenta. And the approximate location where it should be is shown in red. I've attached an image of this
-
Import multipage PDF as AutoCAD Objects
SLW210 replied to SLW210's topic in AutoLISP, Visual LISP & DCL
Adding number of pages is more work than I have time to spare right now. I am swamped until the first of the year and probably into January at work, plus the holidays. I might work on some things over the Holidays at home if time allows. Lots of options to retrieve... How to write shell script for finding number of pages in PDF? - Stack Overflow A quick look on the BricsCAD issue, seems it is more limited in calling PDFATTACH and PDFIMPORT with the options, though main issue could be the background detection in my code. -
anhhao joined the community
-
tykim joined the community
-
Moving objects within polyline to different layer
Hsanon replied to Hsanon's topic in AutoLISP, Visual LISP & DCL
apologies @mhupp i will not do that again.... -
Lisp exportar todas las presentaciones
ivaj replied to mikarts's topic in AutoLISP, Visual LISP & DCL
Muchas gracias por intentar ayudarme, pero no funciona, lo he copiado literalmente y me sale. " Restituyendo las ventanas en memoria caché - Regenerando presentación. ; error: tipo de argumento erróneo: stringp nil " -
Import multipage PDF as AutoCAD Objects
BIGAL replied to SLW210's topic in AutoLISP, Visual LISP & DCL
Just a comment did find an answer to the get number of pages in a pdf. Found a great link. https://www.robvanderwoude.com/pdftips.php I tested using windows cmd may need a bat maybe use (startapp. Ghostscript d:\gs\gs10.02.1\bin\gswin64c.exe -q -dNODISPLAY -dNOSAFER --permit-file-read="D:\Acadtemp\vba-tutorial-for-autocad-pdf-1.pdf" -c "("D:\\Acadtemp\\vba-tutorial-for-autocad-pdf-1.pdf") (r) file runpdfbegin pdfpagecount = quit" >"D:\acadtemp\pagenum.txt" Exiftool exiftool.exe -PageCount D:\Acadtemp\vba-tutorial-for-autocad-pdf-1.pdf Winodws cmd TYPE D:\Acadtemp\vba-tutorial-for-autocad-pdf-1.pdf 2>NUL | FINDSTR.EXE /R /C:"/Type[ ]*/Page" 2>NUL | FIND.EXE /V "/Pages" | FIND.EXE /C "/Page" >D:\acadtemp\pagenum.txt Tested using windows method with a bat file. (setq shell (vla-getinterfaceobject (vlax-get-acad-object) "shell.application")) (vlax-invoke-method shell 'ShellExecute "D:\\acadtemp\\test.bat") - Yesterday
-
Attempt number 2: This code is intended to always return a centerline whose points are all perfectly equidistant from the margins. This should happen in all cases where two LWPOLYLINEs are provided, one for each margin. The case of islands has not been considered yet. The resulting centerline is geometrically dense. This can probably be simplified in a future version. The approach taken in this code has been to obtain points from the normals and the bisectors of each margin, which are then combined at the end to build a list of points. Therefore, it is a fragmentary and massive approach. For this reason, the code is not very fast. However, there is another, more elegant approach, based on dynamically relating the geometry of both margins. It is more complex, but it would also be faster, and the error margins would be “bridgable”. If this thread has enough life in it, I may feel sufficiently motivated to finish it. That’s all for now. ;|*********************** CENTER-LINE ************************* ************************ G L A V C V S ************************* ************************** F E C I T *************************** |; (defun c:CLG (/ PI/2 lst e1 e2 l1 l2 lp lp1 lp2 p0 p> p< r1? x m a tol autoInt? ordenaPts interCpta ptEqd) (defun autoInt? (l lp / p0 p1 p2);autointersecci贸n? (if l (setq p1 (polar (car l) (setq a (angle (car l) (cadr l))) 0.001) p2 (polar (cadr l) (+ a PI) 0.001) x (if (not (vl-some '(lambda (p) (if p0 (inters p0 (setq p0 p) p1 p2) (not (setq p0 p)))) lp)) l) ) ) ) (defun ordenaPts (lst / pIni dm d ps? ps lr); puntos en orden (setq pIni (mapcar '(lambda (a b) (/ (+ a b) 2.0)) (car lp1) (car lp2))) (while lst (foreach p lst (if (and dm (/= (min (setq d (distance (if ps ps pIni) p)) dm) dm)) (setq dm d ps? p) (if (not dm) (setq dm (distance (if ps ps pIni) p) ps? p)) ) ) (setq ps ps? ps? nil dm nil lst (vl-remove ps lst) lr (cons (cadr ps) (cons (car ps) lr))) ) lr ) (defun interCpta (pM p1 p2 lp / i? i1 i2 d a b); captura de los m谩rgenes (defun i? (pA pB lp / p0 i dm is a) (foreach p lp (if p0 (if (setq i (inters p0 (setq p0 p) pA pB)) (if (and dm (/= (min (setq d (distance pM i)) dm) dm)) (setq dm d is i) (if (not dm) (setq dm (distance pm i) is i)) ) ) ) (setq p0 p) ) (if is (list (car is) (cadr is) 0.0)) ) (if (and (setq a (i? p1 p2 lp1)) (setq b (i? p1 p2 lp2))) (list a b) ) ) (defun ptEqd (A B e1 e2 / eqDist-f t0 t1 f0 f1 tm fm n i v+- v*); captura punto equidistante (defun v+- (o a b) (mapcar o a b)) (defun v* (p s) (mapcar '(lambda (x) (* x s)) p)) (defun eqDist-f (ds A B e1 e2 / pt d1 d2) (setq pt (v+- '+ A (v* (v+- '- B A) ds)); Punto sobre AB: P(ds) = A + ds (B - A) d1 (distance pt (vlax-curve-getClosestPointTo e1 pt)) d2 (distance pt (vlax-curve-getClosestPointTo e2 pt)) ) (- d1 d2) ) (setq t0 0.0 t1 1.0) (while (and (< (setq n (if n (1+ n) 0)) 100) (> (- t1 t0) 1e-6));m茅todo de bisecci贸n (setq tm (/ (+ t0 t1) 2.0) fm (eqDist-f tm A B e1 e2) ) (if (< (abs fm) 1e-9) (setq n 100 t1 tm t0 tm) (if (< (* (if f0 f0 (eqDist-f t0 A B e1 e2)) fm) 0.0) (setq t1 tm f1 fm) (setq t0 tm f0 fm) ) ) ) (if (< t1 1.0) ; par谩metro final y punto equidistante (v+- '+ A (v* (v+- '- B A) (/ (+ t0 t1) 2.0))) ) ) (if (and (setq e1 (car (entsel "\nSelect FIRST LWPolyline..."))) (= (cdr (assoc 0 (setq l1 (entget e1)))) "LWPOLYLINE") ) (if (and (setq e2 (car (entsel "\nSelect SECOND LWPolyline..."))) (= (cdr (assoc 0 (setq l2 (entget e2)))) "LWPOLYLINE") ) (progn (foreach l l1 (if (= (car l) 10) (setq lp1 (cons (cdr l) lp1)))) (foreach l l2 (if (= (car l) 10) (setq lp2 (cons (cdr l) lp2)))) (setq r1? (> (distance (car lp1) (car lp2)) (distance (car lp1) (last lp2)))) (setq tol 0.01 PI/2 (/ PI 2.) lp1 (if r1? (reverse lp1) lp1)) (foreach e (list e1 e2) (setq p0 nil m nil r? (if (equal e e1) r1?) lp (if (equal e e1) lp2 lp1)) (while (setq p (vlax-curve-getPointAtParam e (setq m (if m ((if r? 1- 1+) m) (if r? (vlax-curve-getEndParam e) 0))))) (if p0 (progn (setq lAB (autoInt? (interCpta p (polar p (setq a (+ (angle p0 p) PI/2)) 10000) (polar p (+ a PI) 10000) lp) (if (equal e e1) lp1 lp2));NORMAL AL COMIENZO DEL SEGMENTO lst (if lAB (cons (ptEqd (car lAB) (cadr lAB) e1 e2) lst) lst) ) (if (setq p> (vlax-curve-getPointAtParam e ((if r? 1- 1+) m))) (setq lAB (autoInt? (interCpta p (polar p (setq a (/ (+ (angle p p0) (angle p p>)) 2.)) 10000) (polar p (+ a PI) 10000) lp) (if (equal e e1) lp1 lp2)) ; Bisectriz lst (if lAB (cons (ptEqd (car lAB) (cadr lAB) e1 e2) lst) lst) lAB (autoInt? (interCpta p (polar p (setq a (+ (angle p p>) PI/2)) 10000) (polar p (+ a PI) 10000) lp) (if (equal e e1) lp1 lp2));NORMAL AL FINAL DEL SEGMENTO lst (if lAB (cons (ptEqd (car lAB) (cadr lAB) e1 e2) lst) lst) ) ) (setq p< p0 p0 p) ) (if (setq p> (vlax-curve-getPointAtParam e ((if r? 1- 1+) m))) (setq lAB (autoInt? (interCpta p (polar (setq p0 p) (setq a (+ (angle p0 p>) PI/2)) 10000) (polar p0 (+ a PI) 10000) lp) (if (equal e e1) lp1 lp2)) lst (if lAB (cons (ptEqd (car lAB) (cadr lAB) e1 e2) lst) lst) ) ) ) ) ) (vla-AddLightWeightPolyline (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-Make-Variant (vlax-SafeArray-Fill (vlax-Make-SafeArray 5 (cons 0 (- (length (setq lst (reverse (ordenaPts lst)))) 1))) lst)) ) ) ) ) (princ) )
-
Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
Clint replied to Clint's topic in AutoLISP, Visual LISP & DCL
Hi Steven P and all the fine colleagues here, I have been distracted by producing content for a department-wide customization package based in BricsCAD. Steven P, Your comments are sound and will be pursued. My lack of focus on my programming learning shows - embarrassingly. Let's see what i can do about gaining LISP knowledge and its practical application! Thanks for everything. Clint -
Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
Clint replied to Clint's topic in AutoLISP, Visual LISP & DCL
@devitg I thank you for your suggested subject line (of course!) Much more so, your submission to eliminate all undesired layer name text cases. Thanks, Clint -
Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
Clint replied to Clint's topic in AutoLISP, Visual LISP & DCL
Hi @troggarf I will try it but the caveat is that I am applying this customization to BricsCAD. I greatly appreciate your concern and generosity! Clint -
strahinj joined the community
- Last week
-
Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
troggarf replied to Clint's topic in AutoLISP, Visual LISP & DCL
I use the below code to force all layers to uppercase. I don't remember who wrote it but it is most appreciated: ;Change All Layer Names to Uppercase (vl-load-com) (vlax-map-collection (vla-get-layers (vla-get-activedocument (vlax-get-acad-object) ) ) '(lambda (x) (vla-put-name x (strcase (vla-get-name x))) ) ) (defun lva (/ kw kval doc adoc lao cnt inc cvprt blk pw) ;Put this lisp to Appload StartUp Suite (vl-load-com) (setq kval :vlax-true) (setq doc (vlax-get-object "AutoCad.Application") adoc (vla-get-ActiveDocument doc) lao (vla-get-Layouts adoc) cnt (vla-get-Count lao) inc 0 ) (repeat cnt (setq cvprt (vla-Item lao inc) inc (+ inc 1) blk (vla-get-Block cvprt) ) (vlax-for itm blk (if (vlax-property-available-p itm 'DisplayLocked) (progn (vla-put-DisplayLocked itm kval) (vla-update itm) ) ) ) ) (princ) ) -
Help Appreciated: Force Existing Layer Names to UPPER CASE Not Working
ScottMC replied to Clint's topic in AutoLISP, Visual LISP & DCL
Excellent and encourages me all the more to learn more than lean so much.. Found a solution as when using a text with a space in front, it's automatically ignored.. Just slip this in after the: v (vla-get-TextString o) v (vl-string-left-trim " " v) ;; https://www.cadtutor.net/forum/topic/26510-remove-the-space-from-a-text/page/4/#findComment-324578 -
Most times anything can be done if you throw enough money at it. So what I am saying the solution may come at a cost. With no txt file to look at makes further comments difficult, what happens if you open the file in Excel ?
-
That is a classic Civil 3D export nightmare when you don't have the source file - the pain is real. Since re-generating the table is off the table for you, a smart LISP is definitely the most robust way to solve this. It's a tricky job because the routine needs to accurately parse the stationing text and map the Area MTEXT entities to the right Volume and Cumulative Volume fields based on their coordinates. I hope one of the LISP experts can jump in and help you get that final, streamlined routine working!
-
juarezlandscapingservices joined the community -
maksyo joined the community
-
Lisp exportar todas las presentaciones
mikarts replied to mikarts's topic in AutoLISP, Visual LISP & DCL
Hola. Contesto desde el móvil y sin probarlo, pero si no me equivoco bastaría con introducir el guión modificando esta parte del código así: (command "_exportlayout" (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-" presentacion ) ;(getvar "ctab") ".dwg") @ivaj Ya nos dices si te va. -
Lisp exportar todas las presentaciones
devitg replied to mikarts's topic in AutoLISP, Visual LISP & DCL
@ivaj Please upload tomo.dwg -
Obviously, this has now become something more than just the search for a solution to a single user’s problem. First of all, I should say that I myself was also reluctant to accept the concept of equidistance advocated by @GP_ and @dexus For the simple reason that applying this principle forced me to accept that the centerline should be the same in these two drawings. Equidistance requires ignoring those areas of the margins that do not geometrically affect the axis. This, which initially caused me some resistance, I eventually came to accept conceptually when I realized that it could serve as a criterion for defining what is a “recodo/inlet” and what is not. So I have abandoned my previous approach and adapted it to this new situation. Having made this clarification, I must say that this concept of equidistance makes the calculation of a centerline more feasible. I’ve been running some tests with Dexus’s latest code, which is the best so far. However, I’ve discovered some “holes” that I hadn’t noticed before. I’m attaching a few images showing this. In my view, these are conceptual errors rather than geometric limitations. And what can we consider “geometric limitations”? I believe that, in any case, every vertex of the centerline must be equidistant from both margins. If this is not the case, the result is not correct. However, the intermediate regions along each segment may be subject to geometric limitations depending on the desired precision. Therefore, in bends or turns, the points taken within the adjustment or “problematic” segments may deviate (within a tolerance) from strict equidistance. The goal, therefore (in my opinion), should be to achieve equidistance at every vertex and to remain within a tolerance in the intermediate zone of each segment. After everything written here so far, some might wonder: is it really possible to obtain a centerline that meets these requirements? As far as I’m concerned, I’m running some tests. GusanoAcad.mp4 I’ll post something over the weekend
-
Seeking the UNMI.LSP routine (original source unavailable)
p7q replied to p7q's topic in AutoLISP, Visual LISP & DCL
Sooo thanks.It hadn't occurred to me. -
Seeking the UNMI.LSP routine (original source unavailable)
SLW210 replied to p7q's topic in AutoLISP, Visual LISP & DCL
It unmirrors blocks.
