Leaderboard
Popular Content
Showing content with the highest reputation since 02/27/2026 in all areas
-
I am not good as the others but try this. It will build what you want to achieve but not exactly as what was shown in the image. Maybe other can improve the code. (defun c:LayerLegend (/ doc lays lay laylist layname laycolor laydesc pt x y starty rowH txtH headH colHT col1 col2 col3 totalH legendBlock w) (defun GetTextWidth (txt height / doc ms txtObj minp maxp w) (if (or (not txt) (= txt "")) 0 (progn (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq ms (vla-get-ModelSpace doc)) ;; create temp text off-screen (setq txtObj (vla-AddText ms txt (vlax-3d-point -1000 -1000 0) height)) ;; initialize safearrays (setq minp (vlax-make-safearray vlax-vbDouble '(0 . 2))) (setq maxp (vlax-make-safearray vlax-vbDouble '(0 . 2))) ;; get bounding box safely (vl-catch-all-apply '(lambda () (vla-GetBoundingBox txtObj 'minp 'maxp) )) ;; width in X direction (setq w (abs (- (vlax-safearray-get-element maxp 0) (vlax-safearray-get-element minp 0)))) ;; delete temp text (vla-Delete txtObj) w ) ) ) (vl-load-com) (setq rowH 8.0) (setq txtH 2.0) (setq headH 2.5) (setq colHT 1.0) (setq col1 35.0) ;; fixed column 1 width (setq col2 50.0) ;; fixed column 2 width (setq col3 65.0) ;; fixed column 3 width (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq lays (vla-get-Layers doc)) (setq laylist '()) (vlax-for lay lays (setq layname (vla-get-name lay)) (setq laydesc (if (vlax-property-available-p lay 'Description) (vla-get-description lay) "")) ;; Skip 0, Defpoints, XREF (if (and (/= layname "0") (/= (strcase layname) "DEFPOINTS") (not (vl-string-search "|" layname))) (progn (setq laycolor (vla-get-color lay)) (setq laylist (cons (list layname laycolor laydesc) laylist)) ) ) ) (setq laylist (vl-sort laylist '(lambda (a b) (< (strcase (car a)) (strcase (car b)))) ) ) (if (setq legendBlock (tblsearch "BLOCK" "LAYERLEGEND_MARK")) (command "_.erase" "B" "LAYERLEGEND_MARK" "") ) (setq pt (getpoint "\nPick insertion point: ")) (setq x (car pt)) (setq y (cadr pt)) (setq starty y) (setq totalH (* rowH (+ (length laylist) 1))) (entmakex (list '(0 . "LINE")(cons 8 "0") (cons 10 (list x starty 0)) (cons 11 (list (+ x col1 col2 col3) starty 0)))) (entmakex (list '(0 . "TEXT")(cons 8 "0") (cons 10 (list (+ x 3) (- y 5) 0)) (cons 40 headH) (cons 1 "COLOR NUMBER"))) (entmakex (list '(0 . "TEXT")(cons 8 "0") (cons 10 (list (+ x col1 3) (- y 5) 0)) (cons 40 headH) (cons 1 "LAYER NAME"))) (entmakex (list '(0 . "TEXT")(cons 8 "0") (cons 10 (list (+ x col1 col2 3) (- y 5) 0)) (cons 40 headH) (cons 1 "DESCRIPTION"))) ;; header bottom line (entmakex (list '(0 . "LINE")(cons 8 "0") (cons 10 (list x (- y rowH) 0)) (cons 11 (list (+ x col1 col2 col3) (- y rowH) 0)))) (setq y (- y rowH)) (foreach L laylist (setq layname (nth 0 L)) (setq laycolor (nth 1 L)) (setq laydesc (nth 2 L)) ;; Color number text (1 mm) on its layer (entmakex (list '(0 . "TEXT") (cons 8 layname) (cons 10 (list (+ x 3) (+ y -2.2) 0)) (cons 40 colHT) (cons 1 (itoa laycolor)))) ;; Sample line on its layer (entmakex (list '(0 . "LINE") (cons 8 layname) (cons 10 (list (+ x 3) (- y 3) 0)) (cons 11 (list (+ x col1 -3) (- y 3) 0)))) ;; Layer name text on its layer (entmakex (list '(0 . "TEXT") (cons 8 layname) (cons 10 (list (+ x col1 3) (- y 4) 0)) (cons 40 txtH) (cons 1 layname))) ;; Description text (Layer 0) (entmakex (list '(0 . "TEXT") (cons 8 "0") (cons 10 (list (+ x col1 col2 3) (- y 4) 0)) (cons 40 txtH) (cons 1 laydesc))) ;; Row horizontal line (entmakex (list '(0 . "LINE")(cons 8 "0") (cons 10 (list x (- y rowH) 0)) (cons 11 (list (+ x col1 col2 col3) (- y rowH) 0)))) (setq y (- y rowH)) ) (entmakex (list '(0 . "LINE")(cons 8 "0") (cons 10 (list x starty 0)) (cons 11 (list x (- starty totalH) 0)))) (entmakex (list '(0 . "LINE")(cons 8 "0") (cons 10 (list (+ x col1) starty 0)) (cons 11 (list (+ x col1) (- starty totalH) 0)))) (entmakex (list '(0 . "LINE")(cons 8 "0") (cons 10 (list (+ x col1 col2) starty 0)) (cons 11 (list (+ x col1 col2) (- starty totalH) 0)))) (entmakex (list '(0 . "LINE")(cons 8 "0") (cons 10 (list (+ x col1 col2 col3) starty 0)) (cons 11 (list (+ x col1 col2 col3) (- starty totalH) 0)))) (princ) )2 points
-
Nice program as always Tharwat. I think what the OP need is create a table as attached for visual reference.2 points
-
I would ask that you delete your drawings. Why? Because another student could come along and borrow them, make minor changes then submit them as their own drawings thus saving hours of labor. You do all the work and they get the credit. Not kosher at all. Follow me? Addendum: Looks like someone has already done exactly that. Again, take your drawings down. There are plenty of image files (not CAD files for students) to reference. Thank you.2 points
-
Here's my program : https://autolispprograms.wordpress.com/create-layers-from-excel-file/2 points
-
This is what I use, I think the root LISP is the same as the OPs, over time I have added to it: txtfindreplace ;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-and-replace-text/td-p/5649883 (defun FindReplace (Str$ Find$ Replace$ / Cnt# FindLen# Loop Mid$ NewStr$ ReplaceLen# acount) (setq Loop t Cnt# 1 NewStr$ Str$ FindLen# (strlen Find$) ReplaceLen# (strlen Replace$) ) (setq acount 0) (while Loop (setq Mid$ (substr NewStr$ Cnt# FindLen#)) (if (= Mid$ Find$) (progn (setq acount (+ acount 1)) (setq NewStr$ (strcat (substr NewStr$ 1 (1- Cnt#)) Replace$ (substr NewStr$ (+ Cnt# FindLen#))) Cnt# (+ Cnt# ReplaceLen#) );setq );end progn (setq Cnt# (1+ Cnt#)) );if (if (= Mid$ "") (setq Loop nil)) );while (list NewStr$ acount) );defun FindReplace (defun FindReplaceNew (Find$ Replace$ / SS acounter acount ent1 entlist1 entcodes1 EntType Text$ text01 ReplaceWith$ FoundReplaced NewTxt MyBlockEntList BlockCounter ) ;;;Sub Routines ;;;; ;;;;;;;;;;;;;;;;;;;; ;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-entities-inside-a-block/td-p/2644829 (defun getblkitems ( EntName / sel items) ;;Blocks: (setq nfo (entget EntName)) (progn (vlax-for item (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object) ) ) (cdr (assoc 2 nfo)) ) (setq items (cons (vlax-vla-object->ename item) items)) ) ;end vlax ) ; end progn ) ;end defun (defun updateblock ( EntType ent1 entlist1 acount Find$ Replace$ / MyBlockEntList BlockCounter EntType2 ent2 entlist2 ) (if (= EntType "INSERT") (progn ;;Updates block texts & block blocks (setq MyBlockEntList (getblkitems ent1) ) (setq BlockCounter 0) (while (< BlockCounter (length MyBlockEntList)) (setq ent2 (nth BlockCounter MyBlockEntList)) (setq entlist2 (entget ent2)) (setq EntType2 (cdr (assoc 0 entlist2)) ) ;;Attrributes (setq acount (updateattribvalues EntType ent1 entlist1 acount Find$ Replace$)) ;;Texts (if (or (= EntType2 "TEXT")(= EntType2 "MTEXT")(= EntType2 "MULTILEADER")) ;;attributes? (setq acount (updatetext EntType2 ent2 entlist2 acount Find$ Replace$)) ); end if ;;Changes Dimensions (if (or (= EntType2 "DIMENSION") ) (if (= (cdr (assoc 1 entlist2)) "") ;;if has text over ride () (progn (setq acount (updatetext EntType2 ent2 entlist2 acount Find$ Replace$)) ;;same as text -if- ent code 4 used (command ".-refedit" (cdr (assoc 10 entlist1)) "ok" "all" "yes") ;;update block definition (command "refclose" "s") );end progn ) ;end if ); end if (if (= EntType2 "ACAD_TABLE") (setq acount (UpdateTable EntType2 ent2 entlist2 acount Find$ Replace$)) );end if (if (= EntType2 "INSERT") ;;Blocks (setq acount (updateblock EntType2 ent2 entlist2 acount Find$ Replace$)) );end if (setq BlockCounter (+ BlockCounter 1)) ) ; end while );end progn );end if acount ) ;;End Blocks ;;;;;;;;;;;;;;;;;;;; (defun updateattribvalues (EntType ent1 entlist1 acount Find$ Replace$ / ) (setq EntName^ ent1 EntList@ entlist1 EntType$ EntType Text$ (cdr (assoc 1 EntList@)) );setq (if (= EntType$ "INSERT") (if (assoc 66 EntList@) (progn (while (/= (cdr (assoc 0 EntList@)) "SEQEND") (setq EntList@ (entget EntName^)) (if (= (cdr (assoc 0 EntList@)) "ATTRIB") (progn (setq Text$ (cdr (assoc 1 EntList@))) (if (wcmatch Text$ (strcat "*" Find$ "*")) (progn (setq FoundReplaced (FindReplace Text$ Find$ Replace$)) (setq ReplaceWith$ (nth 0 FoundReplaced)) (setq acount (+ acount (nth 1 FoundReplaced))) (entmod (subst (cons 1 ReplaceWith$) (assoc 1 EntList@) EntList@)) (entupd EntName^) );progn );if );progn );end if attrib (setq EntName^ (entnext EntName^)) );while );progn );if );if acount ) ;end defun ;;;;;;;;;;;;;;;;;;;; (defun updatetext (EntType ent1 entlist1 acount Find$ Replace$ / entcodes1 FoundReplaced NewTxt) (progn (setq entcodes1 (gettextdxfcodes entlist1) ) ;list of ent codes containing text. (setq text01 (gettextasstring ent1 entcodes1) ) ;Text as string (if (= text01 nil) () (progn (setq FoundReplaced (FindReplace text01 Find$ Replace$)) (setq NewTxt (nth 0 FoundReplaced)) (setq acount (+ acount (nth 1 FoundReplaced))) (addinnewtext NewTxt entlist1 ent1) )) ;end progn, end if ) ; end progn acount ) ;;;;;;;;;;;;;;;;;;;; (defun UpdateTable ( EntType ent1 entlist1 acount Find$ Replace$ / text01 Newentlist1 counter) (setq counter 0) (setq Newentlist1 '()) (while (< counter (length entlist1)) (if (or (= (nth 0 (nth counter entlist1)) 1)(= (nth 0 (nth counter entlist1)) 302) ) (progn (setq text01 (cdr (nth counter entlist1))) (setq FoundReplaced (FindReplace text01 Find$ Replace$)) (setq NewTxt (nth 0 FoundReplaced)) (setq acount (+ acount (nth 1 FoundReplaced))) (setq text01 NewTxt) (setq Newentlist1 (append Newentlist1 (list (cons (nth 0 (nth counter entlist1)) text01)))) ) ;end progn (setq Newentlist1 (append Newentlist1 (list (nth counter entlist1)))) ;;ignore entity item ) ;end if (setq counter (+ counter 1)) ) ;end while (setq entlist1 Newentlist1) (entmod entlist1) (entupd ent1) acount ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;end subroutines 'findreplace' (setq acount 0) (setq acounter 0) (command "UNDO" "BEGIN") (setq SS (ssget "x" (list '(-4 . "<AND") '(-4 . "<OR") '(0 . "*TEXT") '(0 . "INSERT") '(0 . "ATTDEF") '(0 . "ATTRIB") '(0 . "DIMENSION") '(0 . "*LEADER") '(0 . "POSITIONMARKER") '(0 . "*TABLE") '(-4 . "OR>") (cons 410 (getvar "CTAB")) '(-4 . "AND>") ))) ; end setq, end ss, end list ;;;FILTER SS to text string (while (< acounter (sslength SS)) (setq ent1 (ssname SS acounter)) (setq entlist1 (entget ent1)) (setq EntType (cdr (assoc 0 entlist1)) ) (setq Text$ (cdr (assoc 1 entlist1)) ) ;;change this line to get all texts inc. long texts etc. ;;Changes Attribute Values - In Blocks (setq acount (updateattribvalues EntType ent1 entlist1 acount Find$ Replace$)) ;;Changes Block Texts (if (= EntType "INSERT") (setq acount (updateblock EntType ent1 entlist1 acount Find$ Replace$)) );end if ;;Changes Texts (if (or (= EntType "MTEXT")(= EntType "TEXT") (= EntType "MULTILEADER") (= EntType "POSITIONMARKER") ) (setq acount (updatetext EntType ent1 entlist1 acount Find$ Replace$)) ); end if (if (or (= EntType "DIMENSION") ) (if (= (cdr (assoc 1 entlist1)) "") ;;if has text over ride () (setq acount (updatetext EntType ent1 entlist1 acount Find$ Replace$)) ;;same as text -if- ent code 4 used ) ); end if (if (or (= EntType "ATTDEF")(= EntType "ATTRIB") ) (progn (setq ent2 (entget ent1)) (setq AttText (cdr (assoc 2 ent2))) (setq FoundReplaced (FindReplace AttText Find$ Replace$)) (setq NewTxt (nth 0 FoundReplaced)) (setq acount (+ acount (nth 1 FoundReplaced))) (setq newval Replace$) (entmod (subst (cons 2 NewTxt) (assoc 2 ent2) ent2)) (entupd ent1) );end progn ); end if (if (= EntType "ACAD_TABLE") (setq acount (UpdateTable EntType ent1 entlist1 acount Find$ Replace$)) );end if (setq acounter (+ 1 acounter)) ) ; end while (command "REGEN") (command "UNDO" "END") acount );defun FindReplaceNew (defun c:txtFindReplace( / old_text new_text) (setq old_text (getstring T "OLD Text to replace (replace in this model/paper space and text case as entered): ")) (setq new_text (getstring T "NEW Text: ")) (princ "Changes: ") (princ (FindReplaceNew old_text new_text) ) (princ) )2 points
-
The OP seems to have exited the conversation, but just for others with the same inquiry. As I have mentioned, this is mostly an issue with your PDF editor, the instructions for using the OCR should be in Foxit Help. If this is something you need to do going forward without any effort, you need to use TTF.2 points
-
As most of us use Microsoft Office products I switched from using AutoCAD's Swiss Lt BT TrueType font to ArialNarrow.ttf like SLW210 suggested as it's horizontally compressed to take up less space while being even more easily readable. While hindsight doesn't fix your immediate problem finding a font that doesn't cause issues with your PDF software before you need to output one to PDF again would solve your issues in the future. I've struggled with the same issue even with the full paid version of Adobe with drawings by others usually because of SHX text with various width factors. Never do that with a DWG you want to output to PDF unless you don't want anyone to convert that text back again.2 points
-
I opened your PDF in Acrobat Pro and the text was editable. This seems to be a Foxit issue, though as mentioned, you might want to use a TTF font if that's what Foxit needs. ArialNarrow.ttf is a common replacement IIRC to ISOCP.shx2 points
-
Thanks!! it's working fine. It's okay if it's not exactly the same from mine but as long as it can generate the table it's fine. saved me a lot of time.1 point
-
1 point
-
1 point
-
1 point
-
not sure what your trying to do. you can set entlast before the explode then add all the entities into the selection set. (setq LastEnt (entlast)) (command "_.explode" ss) (setq SS1 (ssadd)) ;create a blank selection set or add to an existing one. (while (setq LastEnt (entnext LastEnt)) (ssadd LastEnt SS1) )1 point
-
I tried this as a test, so finds the #1234 text. It will find 123#456 also. But the lisp as suggested by @Steven P should cater for that. (setq ss (ssget "X" (list (cons 0 "*text")(cons 1 "*#*")))) (princ (sslength ss)) 121 point
-
1 point
-
Have a go at adding this vehicle, they are daunting when you meet them on the road. Let alone the 3 x 19m petrol tankers. Recording 2026-03-01 183700.mp41 point
-
Such a tool would be https://www.theswamp.org/index.php?topic=58808.01 point
-
Unfortunately not with the current version, but I'll certainly consider implementing this functionality in a future version.1 point
-
Have you tried to turn off Object Snaps before you run the script? It looks to me as if your line is snapping to adjacent end of line points instead of plotting the listed coordinates.1 point
-
I moved your thread to the The CUI, Hatches, Linetypes, Scripts & Macros Forum. Your script is missing the blank line at the bottom, so it needed that for enter at the end. Other than that, I ran it in AutoCAD 2000i on my home computer and they all look like your bottom image.1 point
-
In PDF-XChange Editor, I could only edit the Title Border Text. All the node text isn't editable. Using OCR in PDF-XChange, it converted all 5 pages in about 15 seconds. I am using the paid-for version, so not sure if OCR is available in the free version.1 point
-
Just do a google you should be able to find a ISO.TTF font there are thousands of fonts out there. You open c:\Windows\fonts and drag the TTF onto it from memory. ISO3098B ? If your lucky some one may have one already.1 point
-
Like a lot here just remember teaching your children how to drive, no did not crash into things, but went around a roundabout, hands everywhere trying to turn, change gears and me praying as we chugged out.1 point
-
I can do that most of the time with the OCR (Optical character recognition) in Adobe Acrobat Pro. I thought Foxit has an OCR.1 point
-
You may not have a choice here, but can you convert your text to TTF from SHX? PDF should accept that as text.1 point
-
You have a Table in your images, you can change all or one cell in a table with respect to the font style. Is that what your asking for ? If so post an example table dwg. Something like this (vla-SetTextStyle Objtable (+ acDataRow) "Arial") in a lisp.1 point
-
There are several LISP programs around for stripping MTEXT. Solved: strip mtext formatting - Autodesk Community Re: StripMText Issue - Autodesk Community In the MText Editor there is a down arrow on the top right, scroll down to Remove Formatting.1 point
-
I implemented astar using a heap instead of the dictionnary proposed by @GLAVCVS. Safearray is used to simulate the heap. Was done with prompt in Google AI. Results the heap is faster specially if the graph is bigger. ;; ; ;; c:A* by ymg ; ;; Astar implemented with a Heap instead of a dictionnary ; ;; Edges of the Graph are drawn on layer identified by Golbal #Edgeslay ; ;; ; ;; Edges can be lines, lpolylines or 3dpolylines ; ;; You select Start and End points. Shortest is then found and drawn as a ; ;; 3D Polylines on layer, color and lineweight chosen via Global vars ; ;; found at beginning of this routine ; ;; ; ;; Heap has a faster running time than the dictionnary and list approach ; ;; as the size of the graph grows. ; ;; ; (defun c:A* (/ ss graph openH gScore cameFrom found cur curPt curK sNode sKey neighbor nKey t_g val oldG oldCF Startp Endp d minD en param endpar p1 p2 path k link pt i ti) (vl-load-com) (or #acdoc (setq #acdoc (vla-get-activedocument (vlax-get-acad-object)))) (set_errhandler '("CLAYER" "OSMODE" "CMDECHO" "DIMZIN")) (setvar 'CMDECHO 0) (setvar 'OSMODE 1) (setq #Edgelay "Edges" #Pathlay "Path" #Pathcol 1 #Pathlwt 70 #Hptr 0 ) ;; Selecting set of entities defining edges of graph. (if (not (setq ss (ssget "X" (list '(0 . "LINE,LWPOLYLINE,POLYLINE") (cons 8 #Edgelay))))) (progn (alert (strcat "\nError: No entities found on layer " #Edgelay)) (exit) ) ) (vla-startundomark #acdoc) ;; Geting Start and End points. (Use snap to endpoint) (setq Startp (getpoint "\nPick Start Point: ")) (mk_circle Startp 7.5 #Pathcol) (setq Endp (getpoint "\nPick End Point: ")) (mk_circle Endp 7.5 3) (setq ti (getvar 'MILLISECS)) ;Timer for execution time ; Building Graph... (setq graph nil i 0) (repeat (sslength ss) (setq en (ssname ss i) ent (entget en) param 0 endpar (vlax-curve-getEndParam en) i (1+ i) ) (while (< param endpar) (if (= (cdr (assoc 0 ent)) "LINE") (setq p1 (vlax-curve-getstartpoint en) p2 (vlax-curve-getendpoint en) param (1+ endpar) ) (setq p1 (vlax-curve-getPointAtParam en param) p2 (vlax-curve-getPointAtParam en (setq param (1+ param))) ) ) (setq k1 (pt->key p1) k2 (pt->key p2) graph (update-g graph k1 p1 p2) graph (update-g graph k2 p2 p1) ) ) ) (setq minD 1.7e308) ; Initialize to infinity (foreach entry graph (if (< (setq d (distance (cadr entry) Startp)) minD) (setq minD d sNode entry) ) ) (setq sKey (car sNode) openH (heap:new (length graph)) gScore (list (cons sKey 0.0)) cameFrom nil found nil ) (heap:push openH (distance (cadr sNode) Endp) (cadr sNode)) (setq gbti (- (getvar 'MILLISECS) ti)) ;Start of Pathfinding... (while (and (> #Hptr 0) (not found)) (setq cur (heap:pop openH) curPt (cdr cur) curK (pt->key curPt) ) (if (< (distance curPt Endp) 0.1) (setq found T) (foreach neighbor (cddr (assoc curK graph)) (setq nKey (pt->key neighbor) val (assoc curK gScore) t_g (+ (cdr val) (distance curPt neighbor)) ) (if (or (null (setq oldG (assoc nKey gScore))) (< t_g (cdr oldG))) (progn (if oldG (setq gScore (vl-remove oldG gScore))) (setq gScore (cons (cons nKey t_g) gScore)) (if (setq oldCF (assoc nKey cameFrom)) (setq cameFrom (subst (cons nKey curPt) oldCF cameFrom)) (setq cameFrom (cons (cons nKey curPt) cameFrom)) ) (heap:push openH (+ t_g (distance neighbor Endp)) neighbor) ) ) ) ) ) ;; Result Handling (if found (progn (setq path (list curPt) k curK ) (while (setq link (assoc k cameFrom)) (setq pt (cdr link) k (pt->key pt) path (cons pt path) ) ) (mk_3dp path) ) (princ "\nNo path found.") ) (vla-endundomark #acdoc) (setq totaltime (- (getvar 'MILLISECS) ti)) (princ "\n ----- A* Optimized With Gemini ----- ") (princ (strcat "\n Graph Size: " (itoa (length graph)) " nodes")) (princ (strcat "\n Graph Building Time: " (itoa gbti) " ms.")) (princ (strcat "\n Pathfinding Time: " (itoa (- totaltime gbti)) " ms.")) (princ (strcat "\nTotal Execution time: " (itoa totaltime) " ms.")) (*error* nil) ) ;; ; ;; ERROR HANDLING & SYSTEM UTILITIES ; ;; ; ;; ; ;; set_errhandler by Elpanov Evgenyi ; ;; Captures system variable states into global #varl. ; ;; Argument 'l': List of strings naming system variables. ; ;; ; (defun set_errhandler (l) (setq #varl (mapcar (function (lambda (a) (list 'setvar a (getvar a)))) l)) ) ;; ; ;; *error* by Elpanov Evgenyi ; ;; Redefines the *error* function and display an error message. ; ;; Restores system variables and handles exit messages. ; ;; ; (defun *error* (msg) (mapcar 'eval #varl) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*"))) (princ (strcat "\nError: " msg)) ) (princ) ) ;; ; ;; Heap Abstraction Utilities Using Safearray ; ;; ; ;; ; ;; heap:new ; ;; ; ;; Initializes a Variant Safearray as a Minimum-Heap and set the Heap pointer ; ;; Global Var #Hptr to 0 ; ;; ; ;; Argument: size, Total capacity for the Heap. ; ;; ; ;; Return : Safearray Object ; ;; ; (defun heap:new (size) (setq #Hptr 0) (vlax-make-safearray vlax-vbVariant (cons 0 (max 1 (1- size))) '(0 . 1)) ) ;; ; ;; heap:get ; ;; ; ;; Fetch node data at given index in the heap ; ;; ; ;; Arguments: h, Heap name as a safearray object ; ;; idx, Index of the node ; ;; ; ;; Returns: A dotted pair, (Priority . Point) ; ;; ; (defun heap:get (h idx) (cons (vlax-variant-value (vlax-safearray-get-element h idx 0)) (vlax-safearray->list (vlax-variant-value (vlax-safearray-get-element h idx 1))) ) ) ;; ; ;; heap:set ; ;; ; ;; Writes priority and point into heap at index. ; ;; Arguments: h, heap name ; ;; i, index ; ;; prio, double ; ;; p, point. ; ;; ; (defun heap:set (h i prio p / arr) (setq arr (vlax-make-safearray vlax-vbDouble '(0 . 2))) (vlax-safearray-fill arr (mapcar 'float p)) (vlax-safearray-put-element h i 0 (vlax-make-variant prio vlax-vbDouble)) (vlax-safearray-put-element h i 1 arr) ) ;; ; ;; heap:swap ; ;; ; ;; Swaps two elements the heap ; ;; ; ;; Arguments: h, heap name ; ;; i, index of first element ; ;; j, index of second element ; ;; ; (defun heap:swap (h i j / tp tv) (setq tp (vlax-safearray-get-element h i 0) tv (vlax-safearray-get-element h i 1) ) (vlax-safearray-put-element h i 0 (vlax-safearray-get-element h j 0)) (vlax-safearray-put-element h i 1 (vlax-safearray-get-element h j 1)) (vlax-safearray-put-element h j 0 tp) (vlax-safearray-put-element h j 1 tv) ) ;; ; ;; heap:push ; ;; Adds a node, re-sorts heap via sift-up and adjust the heap pointer ; ;; ; ;; Arguments: h, heap name ; ;; prio, priority ; ;; pt, point ; ;; ; ;; Returns: Value of heap pointer ; ;; ; (defun heap:push (h prio pt / i p) (heap:set h #Hptr prio pt) (setq i #Hptr) (while (and (> i 0) (< prio (car (heap:get h (setq p (/ (1- i) 2)))))) (heap:swap h i p) (setq i p) ) (setq #Hptr (1+ #Hptr)) ) ;; ; ;; heap:pop ; ;; ; ;; Removes root node, re-sorts the heap by sift-down updates #Hptr ; ;; ; ;; Argument: h, heap name ; ;; ; ;; Return: root node as dotted pair (Priority . Point) ; ;; ; (defun heap:pop (h / root size i l r s i-prio l-prio r-prio) (if (> #Hptr 0) (progn (setq root (heap:get h 0) #Hptr (1- #Hptr)) (if (> #Hptr 0) (progn (heap:swap h 0 #Hptr) (setq i 0 size #Hptr) (while (< (setq l (1+ (* i 2))) size) (setq r (1+ l) ;; Get priorities once to avoid redundant safearray lookups i-prio (vlax-variant-value (vlax-safearray-get-element h i 0)) l-prio (vlax-variant-value (vlax-safearray-get-element h l 0)) s l ) ;; Check if right child exists and is smaller than left (if (and (< r size) (< (setq r-prio (vlax-variant-value (vlax-safearray-get-element h r 0))) l-prio)) (setq s r l-prio r-prio)) ;; Update smallest index and priority ;; If smallest child is smaller than current, swap (if (< l-prio i-prio) (progn (heap:swap h i s) (setq i s)) (setq i size)) ;; Else, heap property restored ) ) ) root ) ) ) ;; ; ;; GRAPH & DRAWING UTILITIES ; ;; ; ;; ; ;; pt->key ; ;; Converts 3D point to a string key "X,Y,Z". ; ;; Argument 'p': 3D point list. ; ;; ; (defun pt->key (p) (strcat (rtos (car p) 2 2) " " (rtos (cadr p) 2 2) " " (rtos (caddr p) 2 2))) ;; ; ;; update-g ; ;; Links nodes in graph association list. ; ;; ; ;; Arguments: g, graph list ; ;; k, key ; ;; p, point ; ;; n, neighbor. ; ; ;; ; (defun update-g (g k p n / ex) (if (setq ex (assoc k g)) (subst (append ex (list n)) ex g) (cons (list k p n) g) ) ) ;; ; ;; mk_3dp by Alan J Thompson ; ;; ; ;; Entmakes a 3D Polyline. Global Vars #Pathlay, #Pathcol and #Pathlwt have ; ;; to be set in calling program. ; ;; ; ;; Argument: lst, List of 3D points. ; ;; ; ;; Returns: Entity Name of Polyline ; ;; ; (defun mk_3dp (lst / vtx) (if (and lst (> (length lst) 1)) (progn (entmakex (list '(0 . "POLYLINE") '(10 0. 0. 0.) (cons 8 #Pathlay) (cons 62 #Pathcol) (cons 370 #Pathlwt) '(70 . 8) ) ) (foreach vtx lst (entmakex (list '(0 . "VERTEX") (cons 10 vtx) '(70 . 32) ) ) ) (entmakex '((0 . "SEQEND"))) ) ) ) (defun mk_circle (ctr rad color) (entmakex (list (cons 0 "CIRCLE") (cons 10 ctr) (cons 40 rad) (cons 8 #Pathlay) (cons 62 color) (cons 370 #Pathlwt) ) ) ) (princ "\nCommand A* loaded.") (princ) Astar3dHeap.LSP1 point
-
Ok its simple to use vpoint to set your view angles, code is part of a view choice lisp. (if (= look "R")(command-s "-vpoint" "1,0,0")) (if (= look "L")(command-s "-vpoint" "-1,0,0")) (if (= look "F")(command-s "-vpoint" "0,-1,0")) (if (= look "B")(command-s "-vpoint" "0,1,0")) (if (= look "P")(command-s "-vpoint" "0,0,1")) (if (= look "3")(command "_.vpoint" "-1,-1,1")) If you want auto 3 viewports then you need to ask what scale and pick say a point in model so the views can be based around that point. I would use a layout with a title block.1 point
-
How to export, import, backup, and transfer settings to and from AutoCAD products Though if the old computer is unusable, you may have to just start from anew.1 point
