Leaderboard
Popular Content
Showing content with the highest reputation on 07/19/2022 in all areas
-
Try something like this: (setq ss (ssget "_:L" '((0 . "LINE") (-4 . "<OR") (62 . 0) (62 . 7) (62 . 256) (-4 . "OR>"))))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
-
lol didn't account for horizontal in the if statement works now.1 point
-
@Emmanuel Delay THANK YOU MAN. THIS IS NOW WORKING THE WAY I WANTED. TOPIC SOLVED.1 point
-
This uses ldata so the variable is saved to the drawing. If it hasn't been saved yet it will run "SETUP" use this command to change the radius. if the radius has been set it will skip and ask you to select blocks. then line. This command will repeat until canceled by not selecting more blocks. updated entmake to make arcs rather then lines. --edit Seems there was a bit of a bug or I was doing it a stupid way to cause the bug. got rid of the error checking for the line (12 lines of code) and just replaced i with nentselp to select the longer side of the line left when trimmed. Everything should work 100% now. Also if blocks are closer then r vertically this is what will happen. ;;----------------------------------------------------------------------;; ;; CONNECT BLOCK TO LINE (defun C:FOO (/ r ss blklst l1 l2 cir p1 p2 l2 cir p3 p4 p5) (if (setq r (vlax-ldata-get "radius" "R")) (progn) (C:SETUP) ) (while (setq ss (ssget '((0 . "INSERT")))) (setq blklst (mapcar '(lambda (x) (list (cdr (assoc 10 (entget x))) x)) (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))))) (setq blklst ;sorts blocks right to left bottom to top from insertion pointy (mapcar 'cadr (vl-sort blklst '(lambda (a b) (if (equal (cadr (car a)) (cadr (car b)) 1e-6) (< (car (car a)) (car (car b))) (< (cadr (car a)) (cadr (car b))) ) ) ) ) ) (setq l1 (car (entsel "\nSelect Line: "))) y (foreach ent Blklst (setq p1 (vlax-get (vlax-ename->vla-object ent) 'InsertionPoint)) (setq p2 (vlax-curve-getclosestpointto (vlax-ename->vla-object l1) p1)) (entmake (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2))) (setq l2 (entlast)) (entmake (list (cons 0 "CIRCLE") (cons 10 p2) (cons 40 r))) ;delete first line and change r to hard code radius (setq cir (entlast)) (setvar 'cmdecho 0) (command "TRIM" cir "") (command (list l1 p2)) (command (list l2 p2)) (command "") (setvar 'cmdecho 1) (entdel cir) (setq p3 (polar p2 (+ (angle p1 p2) (/ pi 2)) r)) (setq p4 (polar p2 (- (angle p1 p2) (/ pi 2)) r)) (cond ((and (equal (car p1) (car p2) 0.001) (> (cadr p1) (cadr p2))) (setq l1 (car (nentselp p3))) ) ((and (equal (car p1) (car p2) 0.001) (< (cadr p1) (cadr p2))) (setq l1 (car (nentselp p4))) ) ((< (car p1) (car p2)) (setq l1 (car (nentselp p3))) ) ((> (car p1) (car p2)) (setq l1 (car (nentselp p4))) ) ) (entmake (list (cons 0 "ARC") (cons 10 p2) (cons 40 r) (cons 50 (angle p2 p3)) (cons 51 (angle p2 p4)))) ) ) (princ) ) ;;----------------------------------------------------------------------;; ;; SETS R FOR FOO COMMAND (defun C:SETUP () (or (setq *r (vlax-ldata-get "Radius" "R")) (setq *r 0.500)) (if (setq r (getdist (strcat "\nSet Radius [" (rtos *r 2) "]: "))) (vlax-ldata-put "Radius" "R" r) (vlax-ldata-put "Radius" "R" (setq r *r)) ) )1 point
-
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
-
this is a simple routine to put in numbers into the Collatz conjecture. https://en.wikipedia.org/wiki/Collatz_conjecture Command - collatz : graphic mode, like the gif above. - collatztxt : text mode, like below Command: COLLATZTXT input start number : 12302198909 12302198909>36906596728>18453298364>9226649182>4613324591>13839973774>6919986887>20759960662>10379980331>31139940994>15569970497>46709911492>23354955746>11677477873>35032433620>17516216810>8758108405>26274325216>13137162608>6568581304>3284290652>1642145326>821072663>2463217990>1231608995>3694826986>1847413493>5542240480>2771120240>1385560120>692780060>346390030>173195015>519585046>259792523>779377570>389688785>1169066356>584533178>292266589>876799768>438399884>219199942>109599971>328799914>164399957>493199872>246599936>123299968>61649984>30824992>15412496>7706248>3853124>1926562>963281>2889844>1444922>722461>2167384>1083692>541846>270923>812770>406385>1219156>609578>304789>914368>457184>228592>114296>57148>28574>14287>42862>21431>64294>32147>96442>48221>144664>72332>36166>18083>54250>27125>81376>40688>20344>10172>5086>2543>7630>3815>11446>5723>17170>8585>25756>12878>6439>19318>9659>28978>14489>43468>21734>10867>32602>16301>48904>24452>12226>6113>18340>9170>4585>13756>6878>3439>10318>5159>15478>7739>23218>11609>34828>17414>8707>26122>13061>39184>19592>9796>4898>2449>7348>3674>1837>5512>2756>1378>689>2068>1034>517>1552>776>388>194>97>292>146>73>220>110>55>166>83>250>125>376>188>94>47>142>71>214>107>322>161>484>242>121>364>182>91>274>137>412>206>103>310>155>466>233>700>350>175>526>263>790>395>1186>593>1780>890>445>1336>668>334>167>502>251>754>377>1132>566>283>850>425>1276>638>319>958>479>1438>719>2158>1079>3238>1619>4858>2429>7288>3644>1822>911>2734>1367>4102>2051>6154>3077>9232>4616>2308>1154>577>1732>866>433>1300>650>325>976>488>244>122>61>184>92>46>23>70>35>106>53>160>80>40>20>10>5>16>8>4>2>1 code is below ; COLLATZ - 2022.06.17 exceed ; this is a simple routine to plug in numbers into the "Collatz conjecture" ; ; Command List ; collatztxt - Only text output. When you enter a number, it does a Colatz conjecture until it reaches 1. ; collatz - run collatz guesses by 100, starting at 2 It rotates +5 degrees for odd numbers and -5 degrees for even numbers. ; It asks if you want to continue every 100 in case of freezing. (defun c:collatz ( / a ) (setq a 1) (while (getstring "\n continue? (SpaceBar - Continue / ESC - End) - ") (repeat 100 (ex:collatzgr a) (setq a (+ a 1)) ) (princ "\n collatz graph done - from ") (princ (- a 100)) (princ " to ") (princ a) (command "_.Zoom" "_E") ) (princ) ) (defun c:collatztxt ( / n ) (setq n (getreal "\n input start number : ")) (princ (strcat "\n " (rtos n 2 0))) (while (> n 1) (cond ((= (rem n 2) 1) (setq n (+ (* n 3) 1)) (princ (strcat ">" (rtos n 2 0))) ) ((= (rem n 2) 0) (setq n (/ n 2)) (princ (strcat ">" (rtos n 2 0))) ) ) ) (princ) ) (defun EX:COLLATZGR ( n / mspace basedeg deltadeg basept pt2 collatzline ) (vl-load-com) (defun dtr (x) (* pi (/ x 180.0)) ) (defun rtd (x) (* x (/ 180.0 pi)) ) (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq basedeg 90) (setq deltadeg 5) (setq basept (list 0 0 0)) ;(princ (strcat "\n " (rtos n 2 0))) (while (> n 1) (cond ((= (rem n 2) 1) (setq n (+ (* n 3) 1)) (setq pt2 (polar basept (dtr basedeg) n)) (setq basedeg (+ basedeg deltadeg)) (setq collatzline (vla-addline mspace (vlax-3d-point basept)(vlax-3d-point pt2))) (setq basept pt2) ;(princ (strcat ">" (rtos n 2 0))) ) ((= (rem n 2) 0) (setq n (/ n 2)) (setq pt2 (polar basept (dtr basedeg) n)) (setq basedeg (- basedeg deltadeg)) (setq collatzline (vla-addline mspace (vlax-3d-point basept)(vlax-3d-point pt2))) (setq basept pt2) ;(princ (strcat ">" (rtos n 2 0))) ) ) ) (princ) )1 point