Leaderboard
Popular Content
Showing content with the highest reputation on 07/20/2022 in all areas
-
Have a look at this and in particular putcell function, you need to understand about working with Acad <-> excel. Alan Excel library.lsp2 points
-
For this operation, main command was CHAMFER, but usually it's much easier to use FILLET and provide radius 0.0... ACAD.PGP (program parameter file) has "F" as fillet and "CHA" as chamfer, so users usually choose "F" while drafting - that Radius spec. is just for more controlling and managing various possible drafting problems and so FILLET was commonly adopted as more applicable choice...1 point
-
No need to change the radius value. Holding shift while selecting the lines temp sets it to 0. Same for chamfer and some other commands. trim will extend entity's to the trim edge with shift.1 point
-
That should be working for you & it is on this end. tho a little bug with autocad is if your zoomed out too much it might snap to something other then attended when using points. putting "_non" in front of the point usually fixes this issue. (cond ((and (equal (car p1) (car p2) 0.001) (> (cadr p1) (cadr p2))) (setq l1 (car (nentselp "_non" p3))) ) ((and (equal (car p1) (car p2) 0.001) (< (cadr p1) (cadr p2))) (setq l1 (car (nentselp "_non" p4))) ) ((< (car p1) (car p2)) (setq l1 (car (nentselp "_non" p3))) ) ((> (car p1) (car p2)) (setq l1 (car (nentselp "_non" p4))) ) )1 point
-
1 point
-
Use the rectangle command as suggested which is quicker than drawing lines and then joining them, the fillet command also has various options available for using in an LT script. Try running the command and watch the command line which prompts you for input. So in your case you want to start the fillet command and the use the 'radius op[tion (which only needs the letter 'r' in a script followed by the radius you want, you are then prompted again for input and you see an option to select a polyline using the command modifier 'L' will select the last object created and then enter to accept the selection (enter is carried out by using a space or empty line in your script). When you then start the mtext command you can again use command modifiers to select the geometric center of the last object created. The mtext command in a script allows for various options if you watch the command line for the prompts1 point
-
Line 137: (setq SELECTION (SSGET "_X" (list (cons 0 "LWPOLYLINE") (cons 410 (getvar "CTAB"))))) instead of (setq SELECTION (SSGET '((0 . "LWPOLYLINE")))) The "_X" selects everything (also layout tabs). Leaving out the "_X" gives the user the chance to select manually. (getvar "CTAB") gets you the Current Tab, so add that to the filter And you don't need that while. Change line 141 to (setq DUPDISTANCE A) then delete or comment out the while loop. (PRINC "\nSelect lwpolylines to clean ") (setq SELECTION (SSGET "_X" (list (cons 0 "LWPOLYLINE") (cons 410 (getvar "CTAB"))))) (if SELECTION (PROGN (setq A 1.0e-012) (setq DUPDISTANCE A) ; (while (and (EQUAL (TYPE DUPDISTANCE) 'STR)) ; (INITGET 6 "About Help") ; (setq DUPDISTANCE ; (GETDIST ; (STRCAt ; "\nTolerance for vertices to be considered duplicate or [About] <" ; (RTOS A 1) ; ">: " ; ) ; ) ; ) ; (if DUPDISTANCE ; (PROGN (if (OR (EQUAL DUPDISTANCE "About") ; (EQUAL DUPDISTANCE "Help") ; ) ; (PROGN (ABOUT)) ; ) ; ) ; (PROGN (setq DUPDISTANCE A)) ; ) ; ) (setq COUNT 0) (setq MODIFIED 0)1 point
-
1 point
-
1 point
-
@neuri check to see if all the lines are on the same elevation. Also check to see if perspective view is off. (setvar 'perspective 0) ; Turn off Perspective view in current viewport1 point
-
I think the key to the next step is recording your text as you go, I would save that as list, put (setq MyList (list)) somewhere near the beginning to make a blank list, then this bit to populate it all (setq MyList (append MyList (strcat "FF-LINE 01" ) (strcat "CH=" (itoa (+ (atoi sch) f)) "+" (rtos di 2 3)) )) I don't use spreadsheets a lot but once you have the text as a variable you can pass that to the next step to populate the spreadsheet. if you want it a bit more manual than I would make a list with all the points, then write it to a deliminated text file, import that to excel after you have done the CAD stuff. if you can get a LISP to update spreadsheet as you go then each loop set MyList as an empty list, write then text to it and then send to the spreadsheet For now while you are waiting on an answer to the spreadsheet part, add in the text to a variable or list and it will be easier after that1 point
-
I've been working on something similar, and while I haven't nailed it down myself, I can say it is indeed possible. Perhaps this thread might help you out?:1 point
-
As dexus says... replace entsel by ssget, and iterate ... I worked it out for for you. Nice, code; I can use this myself. (defun c:divcut (/ ss i ent end div len elst) (vl-load-com) ;; user selects polylines (princ "\nSelect polylines") (setq ss (ssget (list (cons 0 "LINE,POLYLINE,LWPOLYLINE")))) ;; user sets number of cuts (setq div (getint "\nNumber of divisions: ")) (setq i 0) (while (and (setq ent (ssname ss i)) ;; (setq ent (car (entsel))) (not (vl-catch-all-error-p (setq end (vl-catch-all-apply 'vlax-curve-getEndParam (list ent)) ) ) ) (princ (strcat "\nLongueur de l'objet : " (rtos (setq len (vlax-curve-getDistAtParam ent end))) ) ) (< 0 div) (setq len (/ len div)) ) (progn (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) (repeat (1- div) (setq ent (cadr (CutCurveAtPoint ent (vlax-curve-getPointAtDist ent len)) ) ) ) (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) (setq i (+ i 1)) ) ;;(princ "\nEntité non valide") ) (princ) ) ;;;;;;;;; ;; MESCUT ;; Coupe l'objet sélectionné en tronçons de la longueur spécifiée ;;;;;;;;; (defun c:mescut (/ ss i ent end tot len div elst) (vl-load-com) ;; user selects polylines (princ "\nSelect polylines") (setq ss (ssget (list (cons 0 "LINE,POLYLINE,LWPOLYLINE")))) ;; user sets measure length (setq len (getdist "\nLength of segment: ")) (setq i 0) (while (and (setq ent (ssname ss i)) ;; (setq ent (car (entsel))) (not (vl-catch-all-error-p (setq end (vl-catch-all-apply 'vlax-curve-getEndParam (list ent)) ) ) ) (princ (strcat "\nLongueur de l'objet : " (rtos (setq tot (vlax-curve-getDistAtParam ent end))) ) ) (< 0 len) (setq div (fix (/ tot len))) ) (progn (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) (repeat div (setq ent (cadr (CutCurveAtPoint ent (vlax-curve-getPointAtDist ent len)) ) ) ) (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))) (setq i (+ i 1)) ) ;;(princ "\nEntité non valide") ) (princ) ) ;; Coupe un objet curviligne au point spécifié ;; ;; Arguments ;; ent : l'objet à couper (ename ou vla-object) ;; pt : le point de coupure (coordonnées WCS) ;; ;; Retour ;; une liste des deux objets créés (ename ou vla-object) (defun CutCurveAtPoint (ent pt / vl lst cl start end ec os) (vl-load-com) (and (= (type ent) 'VLA-OBJECT) (setq ent (vlax-vla-object->ename ent) vl T ) ) (cond ((equal pt (vlax-curve-getEndPoint ent) 1e-9) (setq lst (list ent nil)) ) ((equal pt (vlax-curve-getStartPoint ent) 1e-9) (setq lst (list nil ent)) ) ((null (vlax-curve-getParamAtPoint ent pt)) (setq lst (list ent nil)) ) (T (setq start (trans (vlax-curve-getStartPoint ent) 0 1) end (trans (vlax-curve-getEndPoint ent) 0 1) ec (getvar "cmdecho") os (getvar "osmode") ) (setvar "cmdecho" 0) (setvar "osmode" 0) (if (and (wcmatch (cdr (assoc 0 (entget ent))) "*POLYLINE") (= 1 (logand 1 (cdr (assoc 70 (entget ent))))) ) (progn (command "_.break" ent (trans pt 0 1) "@") (setq cl (entlast)) ) (progn (if (= "POLYLINE" (cdr (assoc 0 (entget ent)))) (progn (entmake (entget ent)) (setq vx (entnext ent)) (while (= "VERTEX" (cdr (assoc 0 (entget vx)))) (entmake (entget vx)) (setq vx (entnext vx)) ) (entmake '((0 . "SEQEND"))) (setq cl (entlast) po T ) ) (setq cl (entmakex (entget ent))) ) (command "_.break" ent (trans pt 0 1) end) (and po (setq ent (entlast))) (command "_.break" cl start (trans pt 0 1)) (and po (setq cl (entlast))) ) ) (setvar "cmdecho" ec) (setvar "osmode" os) (setq lst (list ent cl)) ) ) (if vl (mapcar '(lambda (x) (if x (vlax-ename->vla-object x) ) ) lst ) lst ) )1 point
-
The function one object by using entsel. If you use ssget and a loop, you can make it do the commands on multiple polylines. Below is an example of how to make such a loop. The (princ x) should be replaced with the commands from the function you posted. Good luck! ; http://www.lee-mac.com/selsetprocessing.html#repeat (defun c:test2 ( / e i s x ) (if (setq s (ssget)) (progn (setq i 0) (repeat (sslength s) (setq e (ssname s i) x (cdr (assoc 0 (entget e))) i (1+ i) ) (print x) ) ) ) (princ) )1 point
-
I have come to realize that lisp can do quite a lot but their are limitations. I Don't know maybe? Their is always multiple ways to do things. att = "%<\AcObjProp Object(%<\_ObjId 1167638480>%).Area>%" attlst = ("%<\\AcObjProp Object(%<\\_ObjId " "1167638480" ">%).Area>%") handle = "2F466" when you run that through handnet it returns nil. this is further tested by opening the xref and testing for the handle on the same entity & it returns "2F466" From what I have been reading you need a third data point like txt file or registry. to store the "string" data and then read that file into your current drawing. But that seem clunky and messy. Below code doesn't work on xref either. (defun c:TAG (/ att attlst handle id) (setq att (vla-fieldcode (setq obj (vlax-ename->vla-object (car (nentsel "\nSelect Text with field data: ")))))) (setq attlst (sepnumbers att)) (setq handle (vla-get-handle (vla-objectidtoobject (vla-get-activedocument (vlax-get-acad-object)) (cadr attlst)))) (setq str (strcat (car attlst) (rtos (vla-get-objectid (vlax-ename->vla-object (handent handle))) 2 0) (caddr attlst))) (entmake (list (cons 0 "TEXT") (cons 10 (getpoint)) (cons 40 (getvar 'DIMTXT)) (cons 1 str) ) ) ) ;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-separe-number-and-string-in-the-same-string/m-p/2806136/highlight/true#M292581 (defun sepnumbers (str / tmp char currIsNr lastWasNr rslt) (setq tmp "") (while (/= (setq char (substr str 1 1)) "") (setq currIsNr (wcmatch char "#")) (if (eq currIsNr lastWasNr) (setq tmp (strcat tmp char)) (setq rslt (cons tmp rslt) lastWasNr currIsNr tmp char ) ) (setq str (substr str 2)) ) (setq rslt (reverse (cons tmp rslt))) (cond ((not rslt) '( "")) ((eq (car rslt) "") (cdr rslt)) (T rslt) ) )1 point
-
Likewise, though my view is that a 'student asking for help' usually means you have an assignment to complete.. and I am not sure posting an full answer on here would help a lot - course tutors are able to look at the internet and it's forums as well..... Best we should do is offer hints, tips and answer specific questions (such as "why isn't this part working"). So if you can do it manually have you made up a LISP to do 1 block as a layout? Start off simple and just write the code to do it once, see if you can get that to work, then you can work on doing it for all blocks. Might be your process is: Select the block Get the block name Get the block 'bounding box', and it's coordinates Make a new Layout Tab and name it to the block name, set the paper size Make a view port to that paper size Zoom the view port to the bounding box coordinates Once you have the process written down - even simple like this - it is easier to go through each step and make it work. What looks like a complex problem is often a lot of simple problems all in a row. Then your question might change to "I have this LISP, selecting a block and it makes a layout, how can I alter it to select all blocks and make layouts from them all".. which might be a very simple answer1 point
-
1 point
-
Here's another way to do it but the end result is MTEXT and you have to pick the text. (defun c:foo (/ e el p1 p2) (if (and (setq e (car (nentsel "\nPick dimension text: "))) (setq p1 (cdr (assoc 10 (setq el (entget e))))) (setq p2 (getpoint p1 "\nSpecify second point: ")) ) (entmakex (append (vl-remove-if '(lambda (x) (= 330 (car x))) el) (list (cons 10 p2)))) ) (princ) )1 point
-
Try to explain the whole problem next time, but this should sort you: (defun c:alt (/ dimlst doc ss) (vl-load-com) (setq dimlst '("DIM_STYL1" "DIM_STYL2")) ;; Change as necessary (vlax-for dim (vla-get-Dimstyles (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (vl-position (vla-get-Name dim) dimlst) (progn (vla-put-activeDimstyle doc dim) (setvar "DIMALTF" 0.02540) (setvar "DIMAPOST" "M") (vla-copyfrom dim doc)))) (if (setq ss (ssget "_X" '((0 . "DIMENSION")))) (mapcar 'vla-update (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))))) (princ)) Update list as necessary.1 point