All Activity
- Past hour
-
Sakib Sheikh_ BD joined the community
-
Steven P started following Find&open files
-
This will search a location for a file type, in the example searching for LISP files in c:\MyLocation\Here - remember to use a double backslash in any location, and return a list of files names + extensions (also folders if the file type is *.*). (setq myfiles (vl-directory-files "C:\\MyLocation\\Here" "*.lsp" nil)) You could do a search of this list to check if your required file is in there As MHUPP use startapp to open the file, here opens the file in variable Lispfile with notepad (startapp "notepad" Lispfile) MHUPP example was for explorer - I didn't know that method would work for any file type to open the default programme. For the first line here, your file path could be contained in a list, looping through each list item (location) until you find the file you want - could search a few locations if you knew them and want to hardcode them in the LISP, and if fails to find them there use MHUPPs 'getfiled' line for the user to select a folder or file. Use an if, cond or while loop to open the file where it finds it and stop the rest of the loop from looping
- Today
-
mhupp started following Find&open files and Attribute that updates based on location
-
Attribute that updates based on location
mhupp replied to EYNLLIB's topic in AutoLISP, Visual LISP & DCL
Have you looked into reactors to trigger the lisp? Never really used them didn't like the fact something is running without me knowing/realizing it. (defun block-modified-callback (reactor obj) (let* ( (ent (vlr-object-reactor-object reactor)) (pos (cdr (assoc 10 (entget ent)))) ) ;; Define your target area (example: lower-left (0,0), upper-right (10,10)) (if (and (>= (car pos) 0) (<= (car pos) 10) (>= (cadr pos) 0) (<= (cadr pos) 10) ) (princ "\nBlock moved into target area!") ;call lisp ? (princ "\nBlock moved outside target area.") ; ) ) ) (defun C:BlockReact ( / ss i ent obj) (setq ss (ssget "_X" '((0 . "INSERT")))) ;maybe limit to the blocks you want to update (if ss (progn (setq i 0) (while (< i (sslength ss)) (setq ent (ssname ss i)) (setq obj (vlr-object-reactor (vlax-ename->vla-object ent) nil '((:vlr-modified . block-modified-callback)))) (setq i (1+ i)) ) (princ "\nReactors attached to block references.") ) (princ "\nNo blocks found.") ) (princ) ) -Edit Would have to run this after ever copy or insert of a block to add a reactor to it. and i don't know how this affect the performance of the drawing. -
Had a command DIR to start in the folder of the active drawing would open the save prompt like window to allow you to select the file you want. pretty sure if you feed the path to explorer it will use the default program to open the file. (defun C:DIR ( / filePath) (setq dwgPath (getvar "DWGPREFIX")) (setq filePath (getfiled "Select a File to Open" dwgPath "*" 0)) ;limit what types you see by changing "*" (if filePath (progn (startapp "explorer.exe" filePath) (princ (strcat "\nOpening: " filePath)) ) (princ "\nNo file selected.") ) (princ) ) -edit You can also hard code where it stats in like if your documents are in a network drive. (setq filePath (getfiled "Select a Spec File" "C:\\Project\\spec\\" "PDF" 0)) ;look in spec folder for all pdf's
-
If it's not exclusively AutoCAD files, you may be better off using a system tool. What kinds of files would you be looking for? What parameters would you be searching with? What editors would you be opening them with? The more you can tell us, the better we can help you.
-
How to draw the 3d block shown in the image sent?
CyberAngel replied to hemal's topic in AutoCAD 3D Modelling & Rendering
There is not enough information to draw a complete object. What is that line on the other side of the rectangular hole? Where does it start and end? Where are the other edges of that surface? What are the dimensions for the ridge next to the ring, and how does it fit into the opposite side? Where does the flange on the left end? What is going on with that rectangular panel on the right? The whole thing looks like it was designed by M.C. Escher. Wait, I'm looking at it inside out as well as upside down. Your best bet may be to start with the rear face (which we can't see). Draw the two uneven sides separately and extrude them. Draw the rectangular side (with two holes) and extrude that along the Z (?) axis. In other words, separate the task into the four faces and pull them in their own directions. -
Hello again A quick question (I assume this will be an easy answer for the experts on this forum): I often need to search for and open various types of files, primarily in AutoCAD directories but also in others. Is there a quick way to search for and open any file in an editor using a custom Lisp command? Thanks in advance
-
LISP to automatically redefine MTEXT width and Height
SLW210 replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
Another... https://forums.augi.com/showthread.php?170434-MText-width-set-to-zero&s=8d83700e43971c18c05d195f56cd176a&p=1330953&viewfull=1#post1330953 -
cenko joined the community
-
Floor Timber Planks Pattern Hatch
cenko replied to nicolas's topic in The CUI, Hatches, Linetypes, Scripts & Macros
set the scale to 0.001 then work from there- 8 replies
-
- timber hatch
- planks hatch
-
(and 2 more)
Tagged with:
-
That's not a .dwg. Is the original text and the desired results always the same lengths? Is it TEXT or MTEXT? Is the SCALE 1:1000 part of the TEXT/MTEXT? Is the DRAWING TITLE an attribute, TEXT or MTEXT? You could help a lot posting a .dwg.
-
Woolybooly joined the community
-
designpresentation joined the community
-
hemal started following How to draw the 3d block shown in the image sent? and Attribute that updates based on location
-
Attribute that updates based on location
Danielm103 replied to EYNLLIB's topic in AutoLISP, Visual LISP & DCL
Nothing I can think of that’s built in, so you would have to roll something. With lisp, you would use an event to update the attributes, i.e. attached to regen There’s more options with ARX, .NET or Python - Create your own custom field - Create an Overrule that updates the attributes on close -
Add several lisp files to the startup at once
Lee Mac replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Bogging down? Why would it be bogged down? And you think this is simpler than just placing the LISP file in a specific folder without needing to add (load "My lisp") to your one LISP file? -
How to draw the 3d block shown in the image sent?
hemal posted a topic in AutoCAD 3D Modelling & Rendering
I can't figure out how to draw the 3d model shown in the image sent. It is fig 15.47 shown upside down. -
Attribute that updates based on location
BIGAL replied to EYNLLIB's topic in AutoLISP, Visual LISP & DCL
I probably can not help, but post a sample dwg so others can look at it. -
Attribute that updates based on location
EYNLLIB replied to EYNLLIB's topic in AutoLISP, Visual LISP & DCL
Yeah, I can easily do a lisp but I don't want to have my engineers have to run a lisp every time for this workflow. I'm trying to have detail numbers auto populate based on where the detail title is located. So if the detail title attribute is in a specific area of model space, it will always be 1/S3.0, etc -
Attribute that updates based on location
BIGAL replied to EYNLLIB's topic in AutoLISP, Visual LISP & DCL
So if understand correctly you want to place a field value which says "This is inside area1 " You can certainly do as a lisp updating a value but not as a field. Not sure if you can do a COND in a field expression say looking at a multiple XY points. -
EYNLLIB started following Attribute that updates based on location
-
I'm attempting to make a block with an attribute/field that when placed inside a pre-defined set of 4 coordinates (rectangle), the attribute field will update with a custom message. Anyone have any guidance with this? I'm guessing it will need a diesel expression, which I'm not all that familiar with. I'm hoping this is the right forum since it involves coding an expression Thanks
- Yesterday
-
I'll investigate. Any suggestions?
-
Add several lisp files to the startup at once
BIGAL replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Sorry Lee used the Start up suite for years stayed away from the Acaddoc etc, of course in Bricscad the files are different names again. Have used this for years and I think simpler as you can load custom lisp files rather than bogging down the default acad****. I dont understand you can load 50 files via one, yes ONE lisp file added to the startup suite, its just a case of having a (load "My lisp") line in the file for each lisp file. Again I refer to the AUTOLOAD function, this will get ready to load any of the 50 lisps on demand. I have 35 autoloads as part of my single custom lisp. As well as lots of defuns. By using autoload you conserve memory. Yes set the support path to point to your lisp directory and move it up to the top line. -
In Bricscad its known as "BLADE".
-
Hijack command - extract and alter output from vanilla commands
BIGAL replied to darn halo's topic in AutoLISP, Visual LISP & DCL
Using massprop in a lisp is easy you just write it to a file then read what you want out of that file and display. Just always write to a known file. Just a question would the answer not be Litre's. (defun c:vol ( / ent vol) (setq ent (car (entsel "\nPick a solid "))) (command "massprop" ent "" "Y" "D:\\acadtemp\\solid.mpr") (setq fo (open "D:\\acadtemp\\solid.mpr" "R")) (repeat 3 (setq vol (read-line fo)) ) (setq vol (read-line fo)) (close fo) (vl-file-delete "D:\\acadtemp\\solid.mpr") (alert (strcat vol)) (princ) ) -
Rather than a field it can be done by finding the text removing not wanted part, then updating the attribute in the title block, the only stumbling block is it will work easy if the label is in a consistent X&Y location in every layout. No dwg posted so no answer. Need a few layouts.
-
Add several lisp files to the startup at once
Lee Mac replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Oh I'm not mad, I just think you're blinkered into using the Startup Suite. As I've suggested throughout this thread, I would use the acaddoc.lsp. In my acaddoc.lsp, I have the following basic code: ( (lambda ( d ) (foreach x (vl-directory-files d "*.lsp" 1) (if (/= "acaddoc.lsp" (strcase x t)) (load (strcat d "\\" x) nil) ) ) ) "C:\\YourLISPFolder" ) Then, whatever .lsp files I place in "C:\\YourLISPFolder" are automatically loaded on startup - no need to change the Startup Suite, no need to modify the acaddoc.lsp any further - just drop a file into the folder. -
LISP to automatically redefine MTEXT width and Height
Steven P replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
There is also Lee Macs Box Text function for another option... -
LISP to automatically redefine MTEXT width and Height
Steven P replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
I think this one does dynamic columns as well: mtxtWdtHt (defun c:mtxtWdtHt ( / textss ) (setq textss (ssget '((0 . "MTEXT")) ) ) (roundtxtsizes 42 41 textss) (roundtxtsizes 43 46 textss) (princ) ) (defun roundtxtsizes ( width1 width2 textss / ent1 acount oldwidth newwidth) ;;Rounds UP ;;Sub Functions (defun getfroment (ent listorstring entcodes / acount acounter mytext newtext stringtext) ;;get dotted pairs list (setq entlist (entget ent)) ;;; (setq textent (entget (car (entsel)))) (if ( = (cdr (assoc 0 entlist)) "RTEXT") (progn (setq mytext (getrtext entlist)) ) ; end progn (progn (setq enttype (cdr (assoc 0 entlist))) (setq acount 0) (while (< acount (length entlist)) (setq acounter 0) (while (< acounter (length entcodes)) (setq entcode (nth acounter entcodes)) (if (= (car (nth acount entlist)) entcode ) (progn (setq newtext (cdr (nth acount entlist))) (if (numberp newtext)(setq newtext (rtos newtext))) ;fix for real numbers (setq mytext (append mytext (list (cons (car (nth acount entlist)) newtext) )) ) );end progn );end if (setq acounter (+ acounter 1)) );end while (setq acount (+ acount 1)) );end while ;;get string from dotted pair lists (if (= listorstring "astring") ;convert to text (progn (if (> (length mytext) 0) (progn (setq acount 0) (setq temptext "") (while (< acount (length mytext)) (setq temptext (cdr (nth acount mytext)) ) (if (= (wcmatch temptext "LEADER_LINE*") nil)()(setq temptext "")) ;;Fix for Multileader 'Leader_Line' Text (if (= stringtext nil) (setq stringtext temptext) (setq stringtext (strcat stringtext temptext )) );end if (setq acount (+ acount 1)) );end while );end progn );end if (if (= stringtext nil)(setq stringtext "")) (setq mytext stringtext) );end progn );end if );end progn ); end if mytext ) (defun LM:roundup ( n m ) ;; Lee Mac ((lambda ( r ) (cond ((equal 0.0 r 1e-8) n) ((< n 0) (- n r)) ((+ n (- m r))))) (rem n m)) ) ;;End Sub functions ;;Set up. (setq acount 0) ;;update text widths (while (< acount (sslength textss) ) (setq ent1 (ssname textss acount)) (setq oldwidth (cdr (nth 0 (getfroment ent1 string (list width1))) )) (setq newwidth (LM:roundup (atof oldwidth) 2.5 ) ) (entmod (subst (cons width2 newwidth)(assoc width2 (entget ent1)) (entget ent1))) (entupd ent1) (setq acount (+ acount 1)) );end while (princ) ) -
LISP to automatically redefine MTEXT width and Height
pkenewell replied to Someone_Pro's topic in AutoLISP, Visual LISP & DCL
@Someone_Pro I found this at AutoCAD Tips: https://autocadtips1.com/2011/08/13/autolisp-text-box-width/ Command: TXTBOXWIDTH (defun mip-mtext-wrap-BB (en / el SetHandles CheckHandles sclst) (vl-load-com) ;;; Argument: the ename of an mtext ;;; Shrinkwrap the bounding box of selected MText objects ;;; http://discussion.autodesk.com/forums/message.jspa?messageID=5734567 ;;; ShrinkwrapMText v2a.lsp - Joe Burke - 10/13/2007 - Version 2a ;;;;;http://discussion.autodesk.com/forums/thread.jspa?threadID=448625 ;;;; USE: ;;; (mip-mtext-wrap-BB (car(entsel))) ;;; !!!! AutoCAD 2010 2011 2012 ;;; http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/MTEXT-Column-property/m-p/2690952 ;;;Need to change the column type from dynamic to not add the dxf group of 75 with 0 ;;; http://www.theswamp.org/index.php?topic=28243.0 (defun GetAnnoScales (e / dict lst rewind res) ;;; Argument: the ename of an annotative object. ;;; Returns the annotative scales associated with the ;;; ename as a list of strings. ;;; Example: ("1:1" "1:16" "1:20" "1:30") ;;; Returns nil if the ename is not annotative. ;;; Can be used to test whether ename is annotative or not. ;;; Works with annotative objects: text, mtext, leader, mleader, ;;; dimension, block reference, tolerance and attribute. ;;; Based on code by Ian Bryant. (if (and e (setq dict (cdr (assoc 360 (entget e)))) (setq lst (dictsearch dict "AcDbContextDataManager")) (setq lst (dictsearch (cdr (assoc -1 lst)) "ACDB_ANNOTATIONSCALES") ) ;_ end of setq (setq dict (cdr (assoc -1 lst))) ) ;_ end of and (progn (setq rewind t) (while (setq lst (dictnext dict rewind)) (setq e (cdr (assoc 340 lst)) res (cons (cdr (assoc 300 (entget e))) res) rewind nil ) ;_ end of setq ) ;_ end of while ) ;_ end of progn ) ;_ end of if (reverse res) ) ;end (defun CheckHandles (e / dict lst rewind nlst d42 d43 n p ptlst) ;;; Argument: the ename of annotative mtext object. ;;; Returns T if the object has only one scale or ;;; the handles for all scales are proportionally the ;;; same and all scales use the same insertion point. (if (and e (setq dict (cdr (assoc 360 (entget e)))) (setq lst (dictsearch dict "AcDbContextDataManager")) (setq lst (dictsearch (cdr (assoc -1 lst)) "ACDB_ANNOTATIONSCALES") ) ;_ end of setq (setq dict (cdr (assoc -1 lst))) ) ;_ end of and (progn (setq rewind t) (while (setq lst (dictnext dict rewind)) (setq nlst (cons lst nlst) rewind nil ) ;_ end of setq ) ;_ end of while (cond ((= 1 (length nlst))) (t ;; lst is nil so reuse it. (foreach x nlst ;Horizontal width. Can be zero, a null text string. (setq d42 (cdr (assoc 42 x)) ;Vertical height cannot be zero so a divide ;by zero error can't happen. d43 (cdr (assoc 43 x)) n (/ d42 d43) lst (cons n lst) ;Insertion point p (cdr (assoc 11 x)) ptlst (cons p ptlst) ) ;_ end of setq ) ;_ end of foreach (and (vl-every '(lambda (x) (equal n x 1e-4)) lst) (vl-every '(lambda (x) (equal p x 1e-4)) ptlst) ) ;_ end of and ) ) ;_ end of cond ) ;_ end of progn ) ;_ end of if ) ;end (defun SetHandles (lst / oldlst charwidth ht pat) ;;; ;Argument: an entget list. ;;; ;Code 42 is the smallest width of the handles. ;;; ;If 41 is larger than 42 then the handles can be shrunk ;;; ;horizontally given a single line mtext object. ;;; ;;; ;Code 46 is the current height of the handles in 2007/2008. ;;; ;Substitute the actual height from the code 43 value. ;;; ;;; ;Used to determine number of objects modified. (setq lst (entget (cdr(assoc -1 lst)) '("ACAD"))) ;;; (setq oldlst lst) (setq charwidth (* (cdr (assoc 42 lst)) 1.05) ;_1.035 ht (cdr (assoc 43 lst)) lst (subst (cons 41 charwidth) (assoc 41 lst) lst) lst (subst (cons 46 ht) (assoc 46 lst) lst) lst (if (assoc 75 lst) ;;; 75 - òèï êîëîíîê (subst (cons 75 0) (assoc 75 lst) lst) (append lst (list(cons 75 0))) ) ) ;_ end of setq ;;;Code 46 is the current height of the handles in 2007/2008. ;;;Substitute the actual height from the code 43 value. (if (and (setq pat (assoc -3 lst)) (eq "ACAD" (caadr pat)) ) ;_ end of and (progn (if (assoc 46 lst) ;;;Code 46 is the current height of the handles in 2007/2008. ;;; Remove extended data regarding height if found. (setq pat '(-3 ("ACAD"))) (progn (setq pat (cons -3 (list (subst (cons 1040 ht) (assoc 1040 (cdadr pat)) (cadr pat)) ;_ end of subst ) ;_ end of list ) ;_ end of cons ) ;_ end of setq ) ;_ end of progn ) ;_ end of if (setq lst (subst pat (assoc -3 lst) lst)) ) ) ;_ end of if (setq lst (entmod lst)) ) ;end SetHandles (if (= (cdr (assoc 0 (setq EL (entget en '("*"))))) "MTEXT") (progn (cond ((and (setq sclst (GetAnnoScales en))(CheckHandles en)) ;_ end of and (vl-cmdf "._chprop" en "" "_Annotative" "_No" "") ;(SetHandles (entget ename)) (SetHandles el) (vl-cmdf "._chprop" en "" "_Annotative" "_Yes" "") (foreach x sclst (vl-cmdf "._objectscale" en "" "_Add" x "") ) ;_ end of foreach ) ((not (GetAnnoScales en)) (SetHandles el) ) (t nil) ) ;_ end of cond ) ;_ end of progn ) ;_ end of if ) ;_ end of defun (defun C:TxtBoxWidth (/ ss i) (and (setq ss (ssget "_:L" '((0 . "MTEXT")))) (repeat (setq i (sslength ss)) (mip-mtext-wrap-BB (ssname ss (setq i (1- i)))) ) (setq ss nil) ) )