Jump to content

Leaderboard

Popular Content

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

  1. As someone else noted, there are multiple options for any process in AutoCAD. Find one that works for you and keep moving forward. You can always come back later and experiment with the other options. You may even find something that works better. To align objects, such as the endpoints of lines, there's always object snaps. Do a little research, find out how they work, and you'll save a lot of time. Every transformation command has options to move/rotate/scale to fit one object to another. Another thing to start on immediately is Properties. Open the Properties window and keep it open. Learn what the values are and what they mean. Once you understand properties, you'll be a long way down the road to mastering AutoCAD.
    1 point
  2. @Nikon There were a few errors in the code you posted .. FWIW here are some modifications with comments. ;; Create a new text style and replace all styles in the drawing (defun c:cr-txtst-sel2 ;; RJP - Localize all variables (/ acaddoc eo ff i objstyle oldcmd select ss styles) (vl-load-com) ;; RJP - Check that the font can be found otherwise BOOM! Also search for the system font not tied to a CAD version (if (findfile (setq ff (strcat (getenv "WINDIR") "\\FONTS\\ARIALN.ttf"))) ;; (findfile (setq ff "C:\\Program Files\\Autodesk\\AutoCAD 2019\\Fonts\\ARIALN.ttf")) (progn (setq acaddoc (vla-get-activedocument (vlax-get-acad-object))) (setq styles (vla-get-textstyles acaddoc)) ;; Add the style named "ArialN0" (setq objstyle (vla-add styles "ArialN0")) ;; Assign fontfile "ARIALN.ttf" to the style (vla-put-fontfile objstyle ff) ;; Optional: Make the new style Active (vla-put-activetextstyle acaddoc objstyle) ;; Replace All/Select texts with the ArialN0 style (initget "All Select") (if (= "All" (setq select (getkword "\nSelect text to change [All/Select] <Select> : "))) (setq ss (ssget "_X" '((0 . "*TEXT")))) (setq ss (ssget "_:L" '((0 . "*TEXT")))) ) ;; RJP - Check for valid selection (if ss (progn (setq oldcmd (getvar "cmdecho")) (setvar "cmdecho" 0) (repeat (setq i (sslength ss)) (setq eo (vlax-ename->vla-object (ssname ss (setq i (1- i))))) ;; RJP - Check that the text can be modified (if (vlax-write-enabled-p eo) (vlax-put eo 'stylename "ArialN0") ) ) ;; RJP - This line below bombs the code? ;; (vla-endundomark doc) ; Set the style to the current one (vl-cmdf "_-PURGE" "_ST" " " "_N") ; clear unused text styles (setvar "cmdecho" oldcmd) ) ) ) (alert (strcat ff " NOT FOUND!")) ) (princ) )
    1 point
  3. Here's another, not quite as advanced as CAB's BreakAll program, but I had fun writing it - (defun c:breakwith ( / *error* brk brl ent ftr idx sel ) (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (setq ftr (list '(0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE") '(-4 . "<NOT") '(-4 . "<AND") '(0 . "POLYLINE") '(-4 . "&") '(70 . 80) '(-4 . "AND>") '(-4 . "NOT>") (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model")) ) ) (LM:startundo (LM:acdoc)) (cond ( (not (setq sel (LM:ssget "\nSelect objects to break: " (list "_:L" ftr))))) ( (not (setq brk (LM:ssget "\nSelect breaking edges: " (list ftr))))) ( (progn (repeat (setq idx (sslength brk)) (setq idx (1- idx) ent (ssname brk idx) ) (if (not (ssmemb ent sel)) (setq brl (cons (vlax-ename->vla-object ent) brl)) ) ) (null brl) ) (princ "\nAll selected breaking edges were also selected to be broken.") ) ( (repeat (setq idx (sslength sel)) (setq idx (1- idx)) (breakwithlist (ssname sel idx) brl 1) ) ) ) (*error* nil) (princ) ) (defun breakwithlist ( ent lst mxd / cmd enl obj pnt pt1 pt2 tmp ) (cond ( (< 256 mxd)) ;; Just in case ( (setq obj (vlax-ename->vla-object ent) pt1 (vlax-curve-getstartpoint ent) pt2 (vlax-curve-getendpoint ent) pnt (vl-some '(lambda ( x ) (vl-some '(lambda ( p ) (if (and (not (equal p pt1 1e-8)) (not (equal p pt2 1e-8)) ) p ) ) ( (lambda ( l / r ) (repeat (/ (length l) 3) (setq r (cons (mapcar '(lambda ( a b ) a) l '(0 1 2)) r) l (cdddr l) ) ) (reverse r) ) (vlax-invoke obj 'intersectwith x acextendnone) ) ) ) lst ) ) (setq enl (entlast) cmd (getvar 'cmdecho) pnt (trans pnt 0 1) ) (while (setq tmp (entnext enl)) (setq enl tmp) ) (setvar 'cmdecho 0) (vl-cmdf "_.break" (list ent pnt) "_f" "_non" pnt "_non" pnt) (setvar 'cmdecho cmd) (if (entnext enl) (breakwithlist ent lst (1+ mxd)) ) (while (setq enl (entnext enl)) (breakwithlist enl lst (1+ mxd)) ) ) ) ) ;; ssget - Lee Mac ;; A wrapper for the ssget function to permit the use of a custom selection prompt ;; msg - [str] selection prompt ;; arg - [lst] list of ssget arguments (defun LM:ssget ( msg arg / sel ) (princ msg) (setvar 'nomutt 1) (setq sel (vl-catch-all-apply 'ssget arg)) (setvar 'nomutt 0) (if (not (vl-catch-all-error-p sel)) sel) ) ;; Start Undo - Lee Mac ;; Opens an Undo Group. (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) ;; End Undo - Lee Mac ;; Closes an Undo Group. (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) ) (vl-load-com) (princ)
    1 point
  4. Not sure disabling F keys for all programmes is the best solution when you can do it just for AutoCAD
    1 point
  5. Another approach is to use the AutoHotkey program, as follows: 1. Download and install the AutoHotkey program from the address: https://www.autohotkey.com/ 2. Create a text file and name it, for example, NOT_F1.AHK (the AHK extension is mandatory!). The file will contain a single line, as below: F1::return 3. Launch the script by double-clicking on its name. The F1 key will be disabled for ALL your programs! 4. An icon will be created in the System tray, as in the attached picture. 5. If you want to reactivate the F1 key, press Exit and you will restore the functionality of the F1 key.
    1 point
  6. I have done translations before. I'd suggest using Notepad ++ to open the file because it keeps the foreign characters for a better translation than regular Notepad. Then use Google Translate or some other translator and translate the comments only at first. This way you understand what the program is doing. Then, only translate the prompts. If the program works as it is, I wouldn't tinker with it too much. Some of the prompts may have some setq variables to adjust, but keep it simple.
    1 point
  7. You need to modify the key from the CUI manually.
    1 point
  8. Get smaller fingers so you don't hit them by accident? Look at an internet search: 'AutoCAD mapping F keys"
    1 point
  9. You'll find there's several ways to do anything in AutoCAD so you will often receive a variety of correct answers to most questions. I often use grips to Stretch, Move, Rotate, Scale or Mirror lines and objects. https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-BBEA1F71-EB16-4D49-80D9-970A6909F508 When snapping to an endpoint remember you only have to hover over anywhere on that half of the segment with that endpoint and it will display an icon where it will snap to when selected. So if there's multiple endpoints close together find a spot on that segment to pick that not near any others. Keep in mind AutoCAD is 3D so snapping perpendicular to a line whose endpoints have different elevations may not appear perpendicular on your display. The Hitchhiker's Guide to AutoCAD in AutoCAD help is a great place to start, then continue with other links in Getting Started & Have You Tried. https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-2AA12FC5-FBB2-4ABE-9024-90D41FEB1AC3 Hope you enjoy learning AutoCAD as long as you use it, because there will always be more to learn!
    1 point
×
×
  • Create New...