Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/12/2024 in all areas

  1. That's a fun one to write. This should work. Command IBTV, for Insert Block To Vertex (feel free to change the function name) ;; 1. lisp prompt the user to select a ployline. ;; 2. lisp prompt the user to enter the vertex number. ;; 3. lisp inserting a block at the selected vertex. (defun drawInsert (pt Nme) (entmakex (list (cons 0 "INSERT") (cons 2 Nme) (cons 10 pt)))) ;; LW Vertices - Lee Mac ;; Returns a list of lists in which each sublist describes ;; the position, starting width, ending width and bulge of the ;; vertex of a supplied LWPolyline (defun LM:LWVertices ( e ) (if (setq e (member (assoc 10 e) e)) (cons (list (assoc 10 e) (assoc 40 e) (assoc 41 e) (assoc 42 e) ) (LM:LWVertices (cdr e)) ) ) ) ;; Command IBTV, for Insert Block To Vertex (feel free to change the function name) (defun c:ibtv ( / Nme pl vertices ind str_ pt) (setq Nme "3014") ;; 1. lisp prompt the user to select a ployline. (setq pl (ssname (ssget "_+.:S" (list (cons 0 "*POLYLINE"))) 0) ) ;; 2. lisp prompt the user to enter the vertex number. (setq vertices (LM:LWVertices (entget pl))) ;;(princ vertices) (princ (length vertices)) (setq str_ (strcat "\nEnter vertex number (1 to " (itoa (length vertices) ) "): " )) (if (and (setq ind (getint str_)) (> ind 0) (< ind (+ (length vertices) 1)) ) (progn ;; 3. lisp inserting a block at the selected vertex. (setq pt (cdr (assoc 10 (nth (- ind 1) vertices)))) (drawInsert pt Nme) ) ) (princ) )
    2 points
  2. mhupp, Your code is always so well organized. I enjoy your posts answering questions.
    2 points
  3. a few tweaks getkword will allow you to type in a better response instead of numbers. So typeing "C" will pick corner or "Rou" will pick Round. hitting enter (not selecting an option) will default to the Rect. also using getdist instead of getreal still allows you to type in a distance but if you want you have to option of picking two points with a mouse. Allows you to either type FC or FLATCALC to run the command. My 0.02¢ stop juggling variables. use the condition function then inside calculate the points for each style and even draw the polylines. This will get you close using P1 as an example (defun C:FLATCALC () (FC)) (defun C:FC (/ Style Wid Pro P0 P1 P2 P3 P4 P5 C1) (initget "Rect Round Corner") (setq Style (cond ((getkword "\nCoverStyle [<Rect> Round Corner]: ")) ("Rect") ;defaults to rect responce ) ) (setq Wid (getdist "\nMeasured Width :")) ;either input with keyboard or use mouse to pick points (setq Pro (getdist "\nMeasured Projection :")) (setq P0 '(0 0)) (cond ((= "Rect" Style) ;add code here to calultate points for this style (setq P1 (list 0 Wid)) ;then draw the polyline ) ((= "Round" Style) (setq chord (getdist "\nMeasured Chord :")) ;\n is newline to command line (setq mrad (getdist "\nMeasured Radius :")) ;add code here to calultate points for this style (setq P1 (list 0 (+ Wid 1.5)) ;then draw the polyline ;use fillet commands ) ((= "Corner" Style) ;add code here to calultate points for this style (setq P1 (list 0 Wid)) ;then draw the polyline (command "_pline" p0 p1 "C") ) ) (princ) )
    2 points
  4. Glad to hear that. Here is the modified codes for you to work only with the original vertices of selected polylines. (defun c:Test (/ sel int ent get) ;;----------------------------------------------------;; ;; Author : Tharwat Al Choufi - 8.Feb.2022 ;; ;; website: https://autolispprograms.wordpress.com ;; ;;----------------------------------------------------;; (and (princ "\nSelect polylines to locate points on vertices : ") (setq int -1 sel (ssget '((0 . "LWPOLYLINE")))) (or (not (zerop (getvar 'PDMODE))) (setvar 'PDMODE 3)) (while (setq int (1+ int) ent (ssname sel int) ) (setq get (entget ent)) (foreach pt get (and (= (car pt) 10) (entmake (list '(0 . "POINT") pt)) ) ) ) ) (princ) )
    1 point
  5. please keep going.... i'm listening! got snowed in but am about to get my hardware key from the shop and do this from home if I need to. feel like i stumbled onto a gold mine here! @Steven P well thought out and thank you, I'm going to try your version as soon as I can. I am trying to set the z plane thickness in the properties for the drawings this macro makes.
    1 point
  6. I don't think so you could even do it like this. (setq A 5 B 2 C 13) Its just what ever your comfortable with making it easier to read/edit. might be hard to pick up that B is being set to 2 but if its called out with its own setq then it might be a little easier to follow.
    1 point
  7. @Emmanuel Delay First - MANY THANKS!!!! I've added 2 features to the lisp (See attached IBTV2.lsp ) 1. I've let the user to select the block and the lisp extract the block name for the insert command. there are 2 code segments for this task: A. for autocad & bricscad - probebly will not work with *U blocks. B. for bricscad only - should work with *U blocks using getpropertyvalue "EffectiveName~Native" method. 2. I've made a while loop for more vertex number to insert the block to them - exit with ESC. again - many thanks for the help. aridzv IBTV2.lsp
    1 point
  8. This looked liked it was wanting your nentsel LISP from the other day - Select the segment and the block is inserted, then I had a think and you'd need a rule to which end of the segment to place the block (perhaps closest coordinate to the mouse click)
    1 point
  9. I dont use initget any more I think I have provided you with the library function "Multi radio buttons.lsp" just find much easier for users to select rather than type. Like wise 2 lines of code to use it. Multi radio buttons.lsp
    1 point
  10. I got it working with some help. The solution was very simple! (defun c:SetRole (/ ss) (setq MRole ((lambda ( input ) (if (eq "" input) MRole input))(getstring (strcat "\nEnter Model Role: <" (setq MRole (cond ( MRole ) ( "Column" ))) "> or ?: "))) );setq (if(eq MRole "?") (progn (startapp "explorer" (findfile "AST Roles.xlsx")) );progn (progn ;else (setq ss (ssget) nn (sslength ss) i 0 );setq (while (< i nn) (progn (setq ee (cdr (car (entget (ssname ss i))))) (hype_setBeamEntity ee) (hype_getBeamData) (if (= 0 (hype_getError)) (progn (hype_setBeamRole MRole) (hype_modifybeam) );progn (progn (hype_setPlateEntity ee) (hype_getPlateData) (if (= 0 (hype_getError)) (progn (hype_setPlateRole MRole) (hype_modifyplate) );progn );if );progn );if (setq i (1+ i)) ) ;progn ) ;while ) ;progn else ) ;if (princ) )
    1 point
  11. If the user selects option 3, what is the value of MRAD? You use it to calculate p2, p3, p4, and p5. Once you run option 1 or 2, it gets a value, but that value is arbitrary when you run option 3. There are some redundant statements. For instance, you could set RWIDTH to MWIDTH by default, which covers options 1 and 3, and change it for option 2. Then again, I'm not sure what function RWIDTH serves, couldn't you just refer to MWIDTH?
    1 point
  12. Here's one for sloped lines with options: ;| Change the Length of a Line|; ; BY: Tom Beauford ; BeaufordT@LeonCountyFL.gov ; Leon County Public Works Engineering ;(or C:chl (load "ChgLen.lsp"));chl ; (load "ChgLen.lsp") chl ;======================================================= (defun C:chl (/ ActDoc A pick B etype pt1 pt pt2 pt3 pt4 distold dist1 ang1 z1) (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (vla-StartUndoMark ActDoc) (setq A (entsel "\nSelect Entity: ") pick (osnap (cadr A) "endp") B (entget (car A)) etype (cdr(assoc 0 B)) ); setq (princ "\netype = ") (princ etype) (cond ((eq etype "LINE") (progn (setq pt1 (cdr (assoc 10 B)) pt2 (cdr (assoc 11 B))) (if (>(distance pt1 pick)(distance pick pt2)) (setq pt pt1 pt1 pt2 pt2 pt) ) (setq pt3 (list (car pt1)(cadr pt1)) pt4 (list (car pt2)(cadr pt2)) distold (distance pt3 pt4) ang1 (angle pt2 pt1) ) (princ "\nOld Distance=") (princ distold) (initget "Lengthen Shorten Total Elevation Percent Ratio") (if(= ¦¦global¦¦ nil)(setq ¦¦global¦¦ "Total")) (if(setq ¦¦notnil¦¦ (getkword (strcat " [Lengthen/Shorten/Total/Elevation/Percent/Ratio] <" ¦¦global¦¦ ">: ")))(setq ¦¦global¦¦ ¦¦notnil¦¦)) (setvar "cmdecho" 0) (cond ((= ¦¦global¦¦ "Lengthen") (setq dist1 (+ distold (getreal "\nEnter Distance: ")) z1 (+(caddr pt2)(*(/ dist1 distold)(-(caddr pt1)(caddr pt2)))) ) ); Lengthen ((= ¦¦global¦¦ "Shorten") (setq dist1 (- distold (getreal "\nEnter Distance: ")) z1 (+(caddr pt2)(*(/ dist1 distold)(-(caddr pt1)(caddr pt2)))) ) ); Shorten ((= ¦¦global¦¦ "Total") (setq dist1 (getreal "\nEnter New Length: ") z1 (+(caddr pt2)(*(/ dist1 distold)(-(caddr pt1)(caddr pt2)))) ) ); Total ((= ¦¦global¦¦ "Elevation") (setq z1 (getreal "\nEnter Elevation to Trim/Extend: ") dist1 (*(/ distold (-(caddr pt1)(caddr pt2)))(- z1 (caddr pt2))) ) ); Elevation ((= ¦¦global¦¦ "Percent") (setq z1 (+(caddr pt2)(* distold(getreal "\nEnter Slope in %: ")0.01)) dist1 distold ) ); Percent ((= ¦¦global¦¦ "Ratio") (setq z1 (+(caddr pt2)(/ distold(getreal "\nEnter Run/Rise: "))) dist1 distold ) ); Ratio ); cond (setq pt1 (polar pt2 ang1 dist1) pt1 (list (car pt1)(cadr pt1) z1) ) (if pt (setq pt pt1 pt1 pt2 pt2 pt)) (setq B (subst(cons 10 pt1)(assoc 10 B) B) B (subst(cons 11 pt2)(assoc 11 B) B) ) (entmod B) (princ "\nOld Distance=") (princ distold) (princ ", New Distance=") (princ dist1) ); progn ); line ((or(eq etype "ARC")(eq etype "POLYLINE")(eq etype "LWPOLYLINE")) (progn (command "lengthen" pick) ); progn ); ARC, POLYLINE or LWPOLYLINE ); cond (vla-EndUndoMark ActDoc) (princ) )
    1 point
×
×
  • Create New...