Jump to content

All Activity

This stream auto-updates

  1. Today
  2. GLAVCVS

    Hybrid parallel

    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) )
  3. 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
  4. @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
  5. 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
  6. Yesterday
  7. 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) )
  8. 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
  9. BIGAL

    updating an exploded material table

    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 ?
  10. EleenD03

    updating an exploded material table

    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!
  11. 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.
  12. @ivaj Please upload tomo.dwg
  13. Last week
  14. GLAVCVS

    Hybrid parallel

    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
  15. Sooo thanks.It hadn't occurred to me.
  16. It unmirrors blocks.
  17. Hard to say with what little information you are giving. Is it just happening on the MacBook Pro? Can you post the .dwg? What are the computer specifications, graphics card, and driver?
  18. See on archive of the web: UNMI.LSP
  19. I’m trying to obtain the UNMI.LSP AutoLISP routine previously hosted at: http://my.sterling.net/~bdeshawn/unmi.lsp The site has been offline for a long time, and I haven’t been able to reach the original author. If anyone here has the source code, has used this routine before, or can provide details about what the program exactly does, I would greatly appreciate any help or pointers. Thank you in advance to anyone who can share documentation, the LISP file, or a functional equivalent.
  20. Buenos días Me parece muy interesante, se pudiera colocar un guion en el archivo de DWG. Ejemplo: el Archivo de llama Tomo.dwg y tengo varias presentaciones, 001,002, etc. ya la hora de crear el archivo independiente de cada una de las presentaciones me crea un fichero Tomo001.dwg, Tomo002.dwg, etc. y en mi caso me haría falta que saliera Tomo-001.dwg, Tomo-002.dwg, etc.
  21. james9710

    XREF PATH - COPY TO CLIPBOARD

    Great! it worked, thank you so much!
  22. PGia

    Hybrid parallel

    In general, we work with plans for projects of various kinds: engineering, cadastral mapping, and so on. Sometimes we submit proposals for public tenders, but so far without success. @dexus, the performance of your code looks different in that last drawing compared to what I’m seeing on my end. In any case, I think this topic has now entered the realm of a real challenge. @BIGAL: I agree. I think that’s the correct way to draw the centerline in the inlets.
  23. SLW210

    Revit -> PDF -> Autocad

    You need to search for convert Raster to Vector programs. You can use Raster Design on the image files, but still requires some work, it doesn't work on the PDFs though. If they refuse to properly create Vector PDFs or give you a .dwg, your only option is to do them in a separate Raster/Vector program, Raster Design or trace them in AutoCAD.
  24. Welcome aboard. The use of "C:" in a defun name implies the command name, so in code above type "Test" after loading. I would also rename "test" to something that you would call it. (defun c:test ............. ........ ) ; end defun add this a last line and it will run on load ) ; end defun (c:test)
  25. Ok the "add" is only needed if you start excel as it would normally ask to select a fiel including "Blank", if you have Excel already open it will find current workbook. I need to put the add in correct spot not sure why I did not do before. This should work just replace in code. ; Count will be 0 if no excel open but if no workbooks also may return same value. Nil names. ; So a double check count /=0 and wb not "" (princ "\nOpening Excel...") ;; Try to get or create Excel instance (setq myxl (vl-catch-all-apply 'vlax-get-or-create-object '("Excel.Application"))) (if (vl-catch-all-error-p myxl) (progn (prompt "\nError: Could not start Excel.") (exit) ) ) (if (= (vlax-get-property (vlax-get-property myXL 'WorkBooks) 'count) 0) (vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add) ) (vla-put-visible myXL :vlax-true) (vlax-put-property myxl 'ScreenUpdating :vlax-true) (vlax-put-property myXL 'DisplayAlerts :vlax-true)
  26. ILoveMadoka

    Revit -> PDF -> Autocad

    I do not have Revit or the original files. The PDFs were provided to me. I would LOVE the .dwg files but we may not be able to get them from a third party vendor.
  27. I have trouble with the model space viewport - it's on 1/3 of the screen. I try to slide it to enlarge it but it just keeps returning to the initial state. I tried turning all the viewports on and off, command "WSCURRENT", every classical way to resolve the issue but nothing works. The problem occured on a AUTOCAD2024 for MacBook Pro. Thank you in advance.
  28. Danielm103

    Create a stable true rectangle

    Not too hard to create, a real pain to maintain as it must be compiled every time Autodesk decides to break binary compatibility
  1. Load more activity
×
×
  • Create New...