Jump to content

All Activity

This stream auto-updates

  1. Today
  2. fuccaro

    Lisp to draw arc between two lines

    You can't expect from this Forum to write you a Lisp program every time you realize that you could do something faster or just more convenient. Start learning, try changing the existing programs to better suit your needs and post again when you need help.
  3. Thanks for your help. I will work on posting a mock up dwg with steps included....
  4. Yesterday
  5. Mohamed_Essam_2000

    Lisp to make cuts along a line

    Ok, I will try to do it.
  6. BIGAL

    Lisp to make cuts along a line

    Your home work and good time to start learning look into DXF code 62 which is color, and a hint yellow is 2. Look at what 1+ is doing also. Just use Google "dxf code 62 color Autocad" (cons 62 (setq cl (rem (1+ cl) 10))) Look at entmake examples here they should give you the answer.
  7. Mohamed_Essam_2000

    Lisp to draw arc between two lines

    Thanks, that 's great, bro. Can we enable multi-selection so that we can select the two lines together? It will be faster to select the ARC to be trimmed if we enable the multi-selection with the ARC, or just click the side of the ARC to be trimmed. It is also better to enable entering the diameter of the ARC.
  8. Please post a completed dwg still struggling to understand what you want, provide a couple of examples. Show steps in getting to final answer. " Like a chain." that is what I did.
  9. I will agree, frustrating, yet rewarding. I have noticed the same in other forums; people ask for assistance, then ghost the community, not replying whether the solution was from someone within the group, or something entirely different. I will do what I can to respond...though sometimes slightly behind like this response now. LoL. I have been looking into Lee Mac, and will be utilizing his tools to aid in my progression. I will check out the LISP you created, as well as the "getsyntax" from Lee Mac. I really am curious as to how the MDO is functioning...I will update if / when I find the reasoning or cause. Thank you again for the help and suggestions.
  10. I will do so going forward. Thank you for the information.
  11. Mohamed_Essam_2000

    Lisp to make cuts along a line

    Very nice. Thank you, bro. But I need all the lines yellow colored.
  12. Hi @Jonathan Handojo Thanks for the tips. I am trying to learn how to use mapcar better, but it still kind of of confuses me on how to use it. I am getting there but not 100% yet. What I am trying to do now is break this down into subfunctions so its a bit more understandable. I don't get to work on LISP coding as often as I would like so I get lost in some of the code I write. I add comments and maybe using subfunctions would help keep things a bit simpler. @BIGAL LOL ya my code is a bit messy. I get lost in it too sometimes. That's why I add comments here and there so I remember what something does. I was trying to keep away from all the setq variables, but while playing around with this over the weekend I don't think its going to be possible to do what I want without all the variables. What I figured out over the weekend is that it may be easier to break it down into subfunctions. Also at some point I think I need to use the inters function to determine the start point of the steps when paired with another segment. For example, the first image below shows the location of the the point with the current code that I have working right now. The second image is what I actually need the code to do. While doing some research inters seems to do what I need it to do. Also when testing the code you posted, it changed everything to metric, which I assume you work on mostly. The other thing I noticed is that the distance from the angled line in the code you posted is not a static 6". It varies depending on the angle of the line. This 6" is a requirement. You can see it in the second image above.
  13. Thanks BigAl for all your hard work. The blocks wont fit the line most likely the first time. The blocks will be going around a shape and the blocks need to be close to that shape. Shape is based on the specific project and can change. Each shape different for each project. The two ends of the line will be "hooked" into another object to complete a "loop" so the blocks need to be adjusted to stop at the end points, but in-between the adjustments can be made to both be as close to the shape in the center but also fit the 4' segments. Like a chain. Right now, my team is doing this manually and when there are changes to the shape its surrounding, more adjustments are needed. Takes time. I think if its associative, that would cut down allot of work. More Vertex points will most likely need to be created so grab handles can be "snapped" to the 4' segments but that would be quicker than manually adjusting. . The horseshoe shape in my drawing is somewhat typical for a project. I would first make my poly line go around the shape and "hook" into an object on both ends to complete the loop. Next do the array and then adjust the line to fit the segments. It will also make updates quicker if there are changes to the shape...Trying to take something tedious and hopefully make it easier. Thanks again!
  14. fuccaro

    Lisp to draw arc between two lines

    My try: (defun c:pp() (setq dia 2.0) (setq l1 (entget (car (entsel "line1 to keep"))) l2 (entget (car (entsel "\nline2 to keep"))) p1 (assoc 10 l1) p2 (assoc 11 l1) p3 (assoc 10 l2) p4 (assoc 11 l2) pc (if (or (equal p1 p3) (equal p1 p4)) (cdr p1) (cdr p2)) ) (setq del (ssget "X" (list '(0 . "LINE") (cons -4 "<OR") (cons 10 pc) (cons 11 pc) (cons -4 "OR>")))) (repeat (setq n (sslength del)) (entdel (ssname del (setq n (1- n)))) ) (setq l1 (entmake (if (equal pc (cdr p1)) (subst (cons 10 (polar pc (angle pc (cdr (assoc 11 l1))) (/ dia 2.0))) (assoc 10 l1) l1) (subst (cons 11 (polar pc (angle pc (cdr (assoc 10 l1))) (/ dia 2.0))) (assoc 11 l1) l1) )) l2 (entmake (if (equal pc (cdr p3)) (subst (cons 10 (polar pc (angle pc (cdr (assoc 11 l2))) (/ dia 2.0))) (assoc 10 l2) l2) (subst (cons 11 (polar pc (angle pc (cdr (assoc 10 l2))) (/ dia 2.0))) (assoc 11 l2) l2) ))) (setq a1 (angle pc (cdr (assoc 10 l1))) a2 (angle pc (cdr (assoc 10 l2))) d (/ dia 2.0)) (entmake (list '(0 . "ARC") (cons 10 pc) (cons 40 d) (cons 50 a1) (cons 51 a2))) (entmake (list '(0 . "ARC") (cons 10 pc) (cons 40 d) (cons 50 a2) (cons 51 a1))) (entdel (car (entsel "\nArc to delete?"))) (setq del nil) )
  15. hello everyone. how to enable the conversion factor? i would like ti change the coordinates from mm to m. please see screenshot for your reference.
  16. SLW210

    Very Old TurboCAD files

    Did you try the TurboCAD Forum?
  17. fuccaro

    Lisp to make cuts along a line

    Some fun with colors (defun c:ii() (setq lines (ssget '((0 . "LINE"))) n (sslength lines)) (setq gaps (getint "how many gaps? ") gap (getdist "\ngap length? ")) (repeat n (setq line1 (ssname lines (setq n (1- n))) l1 (entget line1) pa (cdr (assoc 10 l1)) pb (cdr (assoc 11 l1)) lay (assoc 8 l1) len (distance pa pb) len1 (/ (- len (* gaps gap)) (1- gaps)) pd pb cl 0 ) (repeat (1- gaps) (setq pc (mapcar '(lambda (b a c) (+ c (* (- b a) (/ gap len)))) pa pb pd)) (setq pd (mapcar '(lambda (b a c) (+ c (* (- b a) (/ len1 len)))) pa pb pc)) (entmake (list (cons 0 "LINE") (cons 10 pc) (cons 11 pd) lay (cons 62 (setq cl (rem (1+ cl) 10))))) ) (entdel line1) ) )
  18. fuccaro

    Lisp to make cuts along a line

    (defun c:pp() (setq lines (ssget '((0 . "LINE"))) n (sslength lines)) (setq gaps (getint "how many gaps? ") gap (getdist "\ngap length? ")) (repeat n (setq line1 (ssname lines (setq n (1- n))) l1 (entget line1) pa (cdr (assoc 10 l1)) pb (cdr (assoc 11 l1)) lay (assoc 8 l1) len (distance pa pb) len1 (/ (- len (* gaps gap)) (1- gaps)) pd pb ) (repeat (1- gaps) (setq pc (mapcar '(lambda (b a c) (+ c (* (- b a) (/ gap len)))) pa pb pd)) (setq pd (mapcar '(lambda (b a c) (+ c (* (- b a) (/ len1 len)))) pa pb pc)) (entmake (list (cons 0 "LINE") (cons 10 pc) (cons 11 pd) lay)) ) (entdel line1) ) (setq lines nil) ) @Mohamed_Essam_2000 Please post your question *only* in the public area of the Forum. Are you sure you don't wish to learn coding?
  19. Ok BIG STEP 1 the insertion point is at wrong point. should be at center of link etc. I will fix for testing. I am still confused what happens if segment length is not 4'. Is it like this for a solution. A contious repeat of the block correctly aligned Is this what happens at change of direction as per forklift image. It was set to 1.5m spacing. I have that code done. Almost there does not use array path. Couple of bugs to fix. Note the vertex point block end i on next segment.
  20. I made a start just opened a blank Notepad and started again. It was to hard for me to try to use what you had.. This is where I am up to and like Jonathan use mapcar. ; https://www.cadtutor.net/forum/topic/93964-create-stepping-lwpolyline-with-getpoint-along-lines/ (defun c:test ( / ) ; By lee-mac (defun LWPoly (lst) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 0) ) (mapcar (function (lambda (p) (cons 10 p))) lst) ) ) ) ;;Check if layers exist, if not create it (if (not (tblsearch "Layer" "WD-Flashing")) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 "WD-Flashing");;Layer Name (cons 70 1);;Printable 0=No 1=Yes (cons 6 "Continuous");;Linetype (cons 62 14);;Colour (cons 290 0) (list -3 (list "AcAecLayerStandard" '(1000 . "") (cons 1000 "Working Drawing ONLY -Elevation Flashing. Use background colour 255,255,255 in hatching over brick"))) ) ) ) (setq lay "WD-Flashing" ;;Sets the layer to be used by the LISP cl (getvar 'clayer) ;;Gets the current layer cmd (getvar 'cmdecho) ) (setvar 'cmdecho 0) (setvar 'clayer lay) (setq oldunit (getvar 'lunits)) (setvar 'lunits 2) (setq oldang (getvar 'aunits)) (setvar 'auints 3) (setq oldangdir (getvar 'angdir)) (setvar 'angdir 0) (setq pi2 (/ pi 2.0)) (setq lst '()) (setq pt1 (getpoint "\nSelect First Point of Flashing: ")) (setq lst (cons pt1 lst)) (setq pt2 (getpoint pt1 "\nSelect Next Point or [ENTER] to Exit")) (setq ang (angle pt1 pt2)) (setq len (distance pt1 pt2)) (setq ver (abs (- (cadr pt1)(cadr pt2)))) (setq numht (fix (/ ver 6.))) (setq hor (abs (- (car pt1)(car pt2)))) (setq numhor (fix (/ hor 6.))) (setq ang2 (- (/ pi 2.) ang)) (setq horstep (* 6.0 (/ (sin ang2)(cos ang2)))) (setq numhor (fix (/ hor horstep))) (setq hyp (/ 6.0 ang2)) (setq pt3 (polar pt1 pi2 (+ 6 hyp))) (setq lst (cons pt3 lst)) (repeat numhor (setq pt4 (mapcar '+ pt3 (list horstep 0.0 0.0))) (setq lst (cons pt4 lst)) (setq pt3 pt4) (setq pt4 (mapcar '+ pt3 (list 0.0 6.0 0.0))) (setq lst (cons pt4 lst)) (setq pt3 pt4) ) (LWPoly lst) )
  21. Some suggestions: You can get rid of Degrees->Radians and use (cvunit 90 "degrees" "radians") I would opt for using vector calculations instead of trigonometry and pythagoras. So for example: (setq pt1 (getpoint "\nSpecify first point <exit>: ")) (setq pt2 (getpoint "\nSpecify first point <exit>: ")) (setq vec (mapcar '- pt2 pt1) dir (mapcar '(lambda (x) (/ x (abs x))) pt2 pt1) ) I just moved computer, so I don't have CAD installed to review your downloaded file there, but probably this is another idea to go.
  22. I went ahead and added a DWG file of a random polyline for testing. There should already be a DWG of the block mentioned above. Please Note: The Polyline will have an unknown length because it will be base on a projects specific parameters and every project is different. A line is created to be a close proximity. Once the Array is created, pulling the grip handles will allow the blocks to fit properly for the length needed as they will be added or removed when adjusted. Please see attached DWG of a random polyline for testing. Thanks BigAl for your input...! Random_polyline_for_Array.dwg
  23. Pierre123

    Lisp works in C3d, but not in Progecad

    Suggest you use ChatGPT, start small, get output, back feed the issues or problems and keep working. I have not written one line of LISP code before, but I wanted to take data from a text file, match the station number on the drawing to a station number on the text file, then place text data from the text file below the station number( of several cross section). It was a bit frustrating over a two day period, having to tell ChatGPT to drop back and rework code, numerous times but I was able to achieve this.
  24. Last week
  25. Thanks for your quick reply! I posted a Dwg with this post. Hopefully you can download it and see the block. Also, it needs to be an associative path array because there is a 95% chance it needs to be altered once created by the user. Pulling on the grip handles of the associated array allows that change as blocks are either added or reduced when adjusting the line. The path draw is just an initial starting point for the user and then it need to be fine tuned once the array is created. At my office we are doing things manually and it is tedious so looking for a better solution...
  26. Did you do another post about using patharray somewhere remember seeing it ? Ok 1st suggestion give up on path array much easier to just use a repeat in a lisp and insert the block aligning along a pline. Thats the way I would do it. You need to post a dwg with real p/line work so can see length of line segments etc. What happens if line length is not a factor of 4 ?
  27. "feed in the list of layers" if you using layer filters then set the correct layer filter, this should result in only those layers now showing, then you can use wblock as this will export out the current display to a new dwg, yes wblock command can be part of a lisp. Just try Wblock follow the prompts it should be clear then.
  28. Hi all, Trying to create a routine for a Path Array but routine wont even load to test. Looking for some help... Goal: Create an associative Path Array using a block from an inserted drawing (MyArray_block.dwg). NOTE: I just have the drawing saved on my desktop so the path will need updating to match your address bar if you test it. Also, I created a DWG file with a random polyline for testing called (Random_polyline_for_Array.dwg). Steps: -User either selects an existing Poly line OR creates a new one for the block to be arrayed to. The line will be based on the parameters of the given project so the length will not be know. Therefor the array must be adjustable. -A drawing containing a block is then inserted and the block is then aligned to the Array Poly line at the start point. -An associative array is created using the block at a distance of 4 feet apart. blocks will overlap. Length will be unknown which is why it needs to be associative. It can then be adjusted using the grip handle until it fits the project parameters. Please see illustrations attached: My block: Example of Associated path array using inserted block when successful: My Code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; User selects or creates Associative path array using an inserted block;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:myarray (/ ln_sel arrayline StartPoint insertpt1 myarrayblock myangle mydistance blksecpoint);; (vl-load-com) (setq oldLUNITS (getvar "LUNITS")) ;Set Units to Architectural. (setvar "LUNITS" 4) ;Say YES to Polyine edits automatically. (setvar "PEDITACCEPT" 1) ;Tell user to select an existing polyline or create a new polyline (princ "\nSelect an existing Polyline or create a new one: ");command prompt ;User selects existing polyline or draws a new polyline for Associative Path Array. Next, Get start point of that Polyline. (setq ln_sel (car(entsel "\n Select a polyline:"))) (if (= (cdr(assoc 0 element)) "POLYLINE") (progn (setq arrayline (vlax-ename->vla-object (car ln_sel )));User saves Polyline (setq StartPoint (vlax-curve-getStartPoint arrayline ));save start point );Else (command "_pline" pause); If no poyline selected, User draws a polyline (setq ln_sel (entget "L" ));save Polyline user either selected or creates (setq StartPoint (vlax-curve-getStartPoint arrayline )); save start point of array path Polyline );end progn );end IF ;NEXT ;Insert block from a drawing. Insertion point same location as startpoint of the Associative Path Array Polyline (setq insertpt1 StartPoint) (command "_insert" "C:\\Users\\B\\Desktop\\MyArray_block.dwg" insertpt1 "" "" "");Insert drawing (saved on desktop for testing purposes) (setq myarrayblock (ssget "L" )); save the block that was just inserted into drawing ;Preset my second point variables for my inserted block. Picking opposite end (setq myangle (atoi "90")); Angle = 90 degrees from start point (setq mydistance (atoi "48")); Distance = 48" (4') from start point ;Make the second known point on block 48 inches at 90 degrees from insert (or start) point (setq blksecpoint (polar insertpt1 (angle myangle) mydistance)); point one is insertion or start point. Point two is 48" at 90 degree angle ;Now align the block ;Align the block to the Path Array using set points on block (if (and (setq blkp1 StartPoint);block insertion point (setq blkp3 blksecpoint); second point on block. 48" distance at 90 angle. (setq blkent myarrayblock);inserted block (setq blkp2 StartPoint); Second alignment point is same as start point (or rotation point) (setq blkp4 (osnap (cadr blkent) "_nea")); snap second block point somewhere on array path polyline ) (command "_.align" blkent "" "_non" blkp1 "_non" blkp2 "_non" blkp3 "_non" blkp4 "" "_No") );End if ;Next, Path Array ;Next do an associative path array using the inserted block that has been aligned (command "arraypath" blkent "" ln_sel "as" "yes" "items" mydistance "" "");; pick Block. Pick line. Distance 48" (4') ;Last, delete the insert block from the drawing (if (/= blkent nil)(command "erase" blkent "")) (setvar "LUNITS" oldLUNITS) );end Any assistance or suggestions are greatly appreciated!!! Thanks all! MyArray_block.dwg
  1. Load more activity
×
×
  • Create New...