Leaderboard
Popular Content
Showing content with the highest reputation on 01/02/2024 in all areas
-
Assuming I've understood what you're looking to achieve, you could potentially use the sendcommand method to accomplish this, i.e.: (defun c:ctext ( / ent enx str ) (while (not (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect command text: "))) (cond ( (= 7 (getvar 'errno)) (prompt "\nMissed, try again.") ) ( (null ent)) ( (not (wcmatch (cdr (assoc 0 (setq enx (entget ent)))) "*TEXT")) (prompt "\nThe selected object is not text or mtext.") ) ( (setq str (cdr (assoc 1 enx)))) ) ) ) ) (if str (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat str "\n"))) (princ) ) (vl-load-com) (princ)3 points
-
To run after select. (princ MyText) replace with (vl-cmdf mytext) Why would you have your run lisp programs as text ? Just make a menu if you can use notepad you can make a menu.2 points
-
@CADSURAY This? (vl-load-com) (defun make_mlead (pt obj / ptlst arr nw_obj) (setq ptlst (append pt (polar pt o_lead d_lead)) arr (vlax-make-safearray vlax-vbdouble (cons 0 (- (length ptlst) 1))) ) (vlax-safearray-fill arr ptlst) (setq nw_obj (vla-addMLeader Space (vlax-make-variant arr) 0)) (vla-put-contenttype nw_obj acMTextContent) (vla-put-textstring nw_obj (strcat "{\\fArial|b0|i0|c0|p34;\"" "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID obj)) ">%).Handle \\f \"%lu2%pr2\">%\"}" ) ) (vla-put-layer nw_obj "Handle Entities") (vla-put-ArrowheadSize nw_obj (* (getvar "TEXTSIZE") 0.5)) (vla-put-TextHeight nw_obj (getvar "TEXTSIZE")) (vla-put-TextBottomAttachmentType nw_obj 0) (vla-put-TextRightAttachmentType nw_obj 1) (vla-put-TextLeftAttachmentType nw_obj 1) (vla-put-TextJustify nw_obj 1) (vla-put-TextDirection nw_obj 5) (vla-put-TextBackgroundFill nw_obj 0) (vla-put-TextFrameDisplay nw_obj 1) (vla-update nw_obj) ) (defun c:length_curve2xls ( / AcDoc Space d_lead o_lead ss factor xls wks lin n obj pt_lead) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) d_lead (* 7.0 (getvar "TEXTSIZE")) o_lead (* pi 0.25) ) (princ "\nSelect objects") (cond ((setq ss (ssget (list '(0 . "*POLYLINE,LINE,ARC,CIRCLE") (cons 67 (if (eq (getvar "CVPORT") 1) 1 0)) (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model")) '(-4 . "<NOT") '(-4 . "&") '(70 . 112) '(-4 . "NOT>") ) ) ) (cond ((null (tblsearch "LAYER" "Handle Entities")) (vlax-put (vla-add (vla-get-layers AcDoc) "Handle Entities") 'color 64) ) ) (initget 2) (setq factor (getreal "\nMultiplicative factor to apply to lengths? <1>: ")) (if (not factor) (setq factor 1.0)) (vla-startundomark AcDoc) (setq xls (vlax-get-or-create-object "Excel.Application")) (or (setq wks (vlax-get xls 'ActiveSheet)) (vlax-invoke (vlax-get xls 'workbooks) 'Add) ) (setq wks (vlax-get xls 'ActiveSheet) lin 2 ) (vlax-put xls 'Visible :vlax-true) (vlax-put (vlax-get-property wks 'range "A1") 'value "Handle") (vlax-put (vlax-get-property wks 'range "B1") 'value "Length") (repeat (setq n (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))) pt_lead (vlax-curve-getStartPoint obj) ) (make_mlead pt_lead obj) (vlax-put (vlax-get-property wks 'range (strcat "A" (itoa lin))) 'value (strcat "\"" (vlax-get-property obj 'Handle) "\"") ) (vlax-put (vlax-get-property wks 'range (strcat "B" (itoa lin))) 'value (* factor (vlax-get-property obj (cond ((eq (vla-get-ObjectName obj) "AcDbArc") "ArcLength") ((eq (vla-get-ObjectName obj) "AcDbCircle") "Circumference") (T "Length") ) ) ) ) (setq lin (1+ lin)) ) (vla-regen AcDoc acactiveviewport) (mapcar 'vlax-release-object (list wks xls)) (gc)(gc) (vla-endundomark AcDoc) ) ) (prin1) )2 points
-
I Got it .. just add this line to ( AlignObjToCurve ) Function in the code ( (vl-position data '(77 109)) (entmod (subst (cons 41 (- (cdr (assoc 41 (entget (vlax-vla-object->ename obj)))))) (assoc 41 (entget (vlax-vla-object->ename obj))) (entget (vlax-vla-object->ename obj)))) )1 point
-
In AutoLISP, there is no direct way to monitor or control the command line in real time to automatically detect and execute a command if it matches specific text. AutoLISP runs sequentially and lacks the ability to interact with the AutoCAD command line in real time. The 'princ' function is used to print text to the command line, but it does not have the ability to detect or execute commands based on what is displayed on the command line. Automatic detection of commands entered on the command line and their subsequent execution is not possible directly through AutoLISP. To achieve similar functionality, it would be necessary to use another programming language or the API provided by AutoCAD, such as the .NET API or the use of event-triggered AutoLISP. These offer broader interaction capabilities and control over commands entered on the AutoCAD command line. Unfortunately, I lack knowledge on how to achieve this.1 point
-
@nikon I apologize as it seems I misinterpreted your request. Now I understand that what you really need is to be able to select some text to be displayed on the command line, is that correct? Here is a starting point that I hope will be useful to you. (defun c:t2cl () (setq IR_ent (car (entsel "\nSelect text: "))) (if IR_ent (progn (setq IR_texto (cdr (assoc 1 (entget IR_ent)))) (princ (strcat "\n" IR_texto)) ) (princ "\nno text selected.") ) (princ) )1 point
-
No it is very possible to do, just trickier and most will not, preferring the simpler ways to do things. Simpler ways have more example code and descriptions to learn from, and you will get more help using them. Compare the 2 codes below. Simpler first: ;;Example, select text string traditionally. 6 lines of code (defun c:GrabText ( / MyEnt MyText) (setq MyEnt (entget (car (entsel "Select text:")))) ; Select an object (setq MyText (cdr (assoc 1 MyEnt))) ; get the text string from the object (princ MyText) (princ) ) More complex. ;;Example, hover over text, press enter or space to select. 67 lines of code (defun c:GrabText ( / MyValue MyEnt EndLoop grsel sela lw pt MyText LastText sel ) (princ (setq Msg "Select text")) (setq MyValue "") (setq MyEnt (list)) (setq EndLoop "No") (while (= EndLoop "No") (setq grsel (grread nil 9 2)) (setq sela (car grsel)) (if (= sela 5) ; Highlight on hover (progn (if lw (redraw lw 4) ) ;Remove any highlight (if (and (setq pt (cadr grsel) ) (setq lw (ssget pt)) (setq lw (ssname lw 0)) (if (or (= LastText (cdr (assoc 1 (entget lw)))) (= (cdr (assoc 1 (entget lw))) nil) ) ; endor (redraw lw 3) (progn (setq MyText (cdr (assoc 1 (entget lw)))) (setq LastText MyText) (princ "\n") (princ LastText) (redraw lw 3) ) ; end progn ) ; end if ) ; end and (redraw lw 3) ) ; end if ) ; end progn ) ; end if (if (= sela 2) ; text entry only "Enter" or "Space" (progn (setq sel (nth 1 grsel)) (if (= (type sel) 'LIST) (progn (setq MyEnt (nentselp sel)) (if (= nil MyEnt) (Princ "\nMissed! Try again.\nSelect text: ") (setq EndLoop "Yes") ) ; end if (redraw lw 4) ; remember to (redraw xyz 3) in originating code to keep highlight (setq sel nil) ) ; end progn (progn (if (= sel 13) ; enter (progn (setq EndLoop "Yes") ) ; end progn ) ; end if (if (= sel 32) ; space (progn (setq EndLoop "Yes") ) ; end progn ) ; end if ) ; end progn ) ; end if list )) ; end progn ; end if text / mouse entry ) ; end while (princ "\nThanks. Selected text: ") (princ MyText) (princ) ) I'll let you decide which one to you want to study and understand first.1 point
-
That worked PEFRECT!!! Thank you so much, this will save me so much time! I thought the command was 'TabSort' my mistake Thank you again, much appreciated!1 point
-
Multi GETVALS.lspHave a look at this it's a front end for your input. Save it to a support path. (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Enter values " "Length " 5 4 "1000" "Width " 5 4 "150" "Number of studs" 5 4 "5" "Stud dia" 5 4 "25" "End space" 5 4 "50" ))) (setq len (atof (nth 0 ans)) wid (atof (nth 1 ans)) num (atof (nth 2 ans)) dia (atof (nth 3 ans)) espc (atof (nth 4 ans)) )1 point