Jump to content

Leaderboard

  1. Saxlle

    Saxlle

    Community Member


    • Points

      5

    • Posts

      187


  2. GLAVCVS

    GLAVCVS

    Community Member


    • Points

      4

    • Posts

      668


  3. Danielm103

    Danielm103

    Community Member


    • Points

      2

    • Posts

      205


  4. Lee Mac

    Lee Mac

    Trusted Member


    • Points

      1

    • Posts

      21,014


Popular Content

Showing content with the highest reputation on 06/23/2025 in all areas

  1. After seeing @BIGAL's suggestion, I'm wondering if I understood correctly what you're asking, Vica. Anyway, I'm attaching a short clip of what I'm talking about. FACTVM de ARCTIS.mp4 I’ve implemented a small emulator of the "pline" command in the base code, but each user should implement the code they need for their specific task instead. Basically, the distance variation from the last stored point in LASTPOINT is displayed above the cursor (though this can be easily changed by modifying the textoGR1 function). Below the cursor, any desired information about the object under it will be shown (or not, if visibility is toggled by pressing the F10 key). This information must be passed to the textoGR2 function as a list of (Property_Name StringValue) pairs. The main code must be implemented in the 'FuncionPrincipal' function.
    3 points
  2. Forgive the Python, only trying to illustrate one possibility. This code creates a spatial filter for a block reference, to simulate a detail. In the image, I created a block of the room, with two references. One has a spatial filter applied and is scaled. You can do the same in lisp, or by hand, make a copy of the block, run the xclip command, draw your polyline perimeter, set XCLIPFRAME to 1 so you can see your frame. instead of a circle, use a polygon with a shape to your liking. My code still needs work as my transformby is wonky(not centered correctly) and I hand drew the leader line lol import traceback from pyrx import Rx, Ge, Gi, Db, Ap, Ed ACDB_INFINITE_XCLIP_DEPTH = 1.0e300 def addFilter_getmat(refid, filter): ref = Db.BlockReference(refid, Db.OpenMode.kForWrite) Db.IndexFilterManager.addFilter(ref, filter) return ref.blockTransform() @Ap.Command() def doit(): try: db = Db.curDb() _ps, refid, _ = Ed.Editor.entSel("\nSelect ", Db.BlockReference.desc()) _ps, cen = Ed.Editor.getPoint("\nGet center: ") _ps, rad = Ed.Editor.getDist(cen, "\nGet radius: ") carc = Ge.CircArc3d(cen, Ge.Vector3d.kZAxis, rad) pts3d, _params = carc.getSamplePoints(20) filter = Db.SpatialFilter() mat = addFilter_getmat(refid, filter) pts2d = [] for pt in pts3d: pt.transformBy(mat) pts2d.append(Ge.Point2d(pt.x, pt.y)) filter.setDefinition( pts2d, Ge.Vector3d.kZAxis, db.elevation(), ACDB_INFINITE_XCLIP_DEPTH, -ACDB_INFINITE_XCLIP_DEPTH, True, ) except Exception as err: print(err)
    2 points
  3. This returns the serial number of the motherboard. It is more unique than the hard drive's serial number and also more unique than the variant of this same function that uses "Select * from Win32_BaseBoard". (defun obt_UUID (/ LObj SObj OSObj UUID) (setq LObj (vlax-create-object "WbemScripting.SWbemLocator") SObj (vlax-invoke LObj 'ConnectServer nil nil nil nil nil nil nil nil) OSObj (vlax-invoke SObj 'ExecQuery "SELECT UUID FROM Win32_ComputerSystemProduct") ) (vlax-for Obj OSObj (setq UUID (vlax-get Obj 'UUID)) ) (foreach Obj (list LObj SObj OSObj) (and Obj (vlax-release-object Obj)) ) UUID ) This might be a good option if you want your program to continue working when the user changes their hard drive but not their motherboard.
    1 point
  4. So you'll need to compile the code otherwise the test can just be overwritten and the LISP used without it. (getenv "COMPUTERNAME") will give you the computer name and this might give you the drive number - based on a drive (setq ser (vla-get-Serialnumber (vlax-invoke (vlax-create-object "Scripting.FileSystemObject") 'getdrive "c:"))) ;;https://www.cadtutor.net/forum/topic/70821-usb-drive-serial-number/
    1 point
  5. 1 point
  6. You can use something like this from the image below (when I run it, it only selects entities with color < 5 and entities with color BYLAYER), this replaces your code from above. After that, you can iterate through the selection set and do what you want to achieve.
    1 point
  7. Try to replace this block of code (replace original code with code from below) ........ (vlax-for ent ms (setq ename (vla-get-objectname ent) clr (vla-get-color ent) lt (vla-get-linetype ent) lyr (vla-get-layer ent) ) ;; Move objects by type & color (cond ((wcmatch ename "AcDb3dSolid,AcDbSurface") (vla-put-layer ent "D-3D-SOL") ) ((and (member ename '("AcDbLine" "AcDbPolyline" "AcDbCircle")) (< clr 5) ) (vla-put-layer ent "D-3D-CLG") ) ((and (member ename '("AcDbLine" "AcDbPolyline" "AcDbCircle")) (>= clr 5) ) (vla-put-layer ent "D-3D-CLM") ) ) ;; Set ByLayer (if (/= clr 256) (progn (vla-put-color ent 256) (setq prop-errors (1+ prop-errors)) ) ) (if (/= (strcase lt) "BYLAYER") (progn (vla-put-linetype ent "BYLAYER") (setq prop-errors (1+ prop-errors)) ) ) (command "-layer" "tr" 0 lyr "") ;;; (vla-put-transparency ent (vlax-make-variant 0)) ;; Track wrong types (if (not (member ename '("AcDbLine" "AcDbPolyline" "AcDbCircle" "AcDb3dSolid" "AcDbSurface" ) ) ) (setq enttype-errors (1+ enttype-errors)) ) ;; Track wrong linetypes (if (not (member (strcase lt) '("BYLAYER" "CONTINUOUS" "CENTER")) ) (setq ltype-errors (1+ ltype-errors)) ) ) ........ After executing the code in file "AA0003-3D-LWT.dwg", I get this in .csv (file name "DWG_Audit_Report"). And, I forget, this part also: ;; Create or set a layer (defun makelayer (name color lw tran) (if (not (tblsearch "layer" name)) (vla-add (vla-get-layers doc) name) ) (vla-put-color (vla-item (vla-get-layers doc) name) color) (vla-put-lineweight (vla-item (vla-get-layers doc) name) lw) (command "-layer" "tr" tran name "") ;;; (vla-put-transparency ;;; (vla-item (vla-get-layers doc) name) ;;; (vlax-make-variant tran) ;;; ) )
    1 point
  8. I've changed ElpanovEvgeniy's code. Now it uses snapping with help from dyndraw.arx by Alexander Rivilis. The topic for dyndraw: https://www.theswamp.org/index.php?topic=9133.0 The latest version seems to be AutoCAD 2019 and the arx can still be downloaded here: http://web.archive.org/web/http://www.maestrogroup.com.ua/support/dyndraw.zip Here is my adaptation, let me know how it functions: offset.lsp
    1 point
  9. Something like this? (defun c:Autoalpha (/ alphabet index increment index_copy num_pref_suffix answ_1 answ_2 num_pref_suffix const letter) (setq alphabet '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" ) ) ; Alphabet string (setq index 0 increment 0 index_copy 0 num_pref_suffix 1 ) (initget 1 "Yes No") (setq answ_1 (getkword "\nDo you want to add a prefix or suffix to letters? [Yes/No]")) (if (= answ_1 "Yes") ; 1. progn (progn (initget 1 "Prefix Suffix") (setq answ_2 (getkword "\nDo you want a prefix or suffix? [Prefix/Suffix]")) ;;; (initget 1 "1 2 3 4 5 6 7 8 9 10") ;;; ;;; (setq num_pref_suffix (getkword "\nChoose the numerical prefix or suffix? [1/2/3/4/5/6/7/8/9/10]")) (initget "Constant cHangeable") (setq const (getkword "\nDo you want the numerical prefix or suffix to be Constant or Changeable? [Constant/cHangeable]")) ; main cond start (cond ; 1. cond ((and (= answ_2 "Prefix") (= const "Constant")) (while (setq pt (getpoint "\nPick point: ")) (cond ((< index (length alphabet)) (setq letter (nth index alphabet)) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq index (1+ index)) ) ((>= index (length alphabet)) (if (< increment (length alphabet)) (progn (setq letter (strcat (itoa num_pref_suffix) (nth index_copy alphabet) (nth increment alphabet))) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq increment (1+ increment)) ) (setq index_copy (1+ index_copy) increment 0 ) ) ) ) ) ) ; 1.cond ; 2. cond ((and (= answ_2 "Prefix") (= const "cHangeable")) (while (setq pt (getpoint "\nPick point: ")) (cond ((< index (length alphabet)) (setq letter (nth index alphabet)) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq index (1+ index)) ) ((>= index (length alphabet)) (if (< increment (length alphabet)) (progn (setq letter (strcat (itoa num_pref_suffix) (nth index_copy alphabet) (nth increment alphabet))) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq increment (1+ increment)) ) (setq index_copy (1+ index_copy) increment 0 num_pref_suffix (1+ num_pref_suffix) ) ) ) ) ) ) ; 2. cond ; 3. cond ((and (= answ_2 "Suffix") (= const "Constant")) (while (setq pt (getpoint "\nPick point: ")) (cond ((< index (length alphabet)) (setq letter (nth index alphabet)) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq index (1+ index)) ) ((>= index (length alphabet)) (if (< increment (length alphabet)) (progn (setq letter (strcat (nth index_copy alphabet) (nth increment alphabet) (itoa num_pref_suffix))) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq increment (1+ increment)) ) (setq index_copy (1+ index_copy) increment 0 ) ) ) ) ) ) ; 3. cond ((and (= answ_2 "Suffix") (= const "cHangeable")) (while (setq pt (getpoint "\nPick point: ")) (cond ((< index (length alphabet)) (setq letter (nth index alphabet)) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq index (1+ index)) ) ((>= index (length alphabet)) (if (< increment (length alphabet)) (progn (setq letter (strcat (nth index_copy alphabet) (nth increment alphabet) (itoa num_pref_suffix))) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq increment (1+ increment)) ) (setq index_copy (1+ index_copy) increment 0 num_pref_suffix (1+ num_pref_suffix) ) ) ) ) ) ) ; 4. cond ) ; main cond end ) ; 1. progn ; 2. progn (progn (while (setq pt (getpoint "\nPick point: ")) (cond ((< index (length alphabet)) (setq letter (nth index alphabet)) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq index (1+ index)) ) ((>= index (length alphabet)) (if (< increment (length alphabet)) (progn (setq letter (strcat (nth index_copy alphabet) (nth increment alphabet))) ;; Insert the letter as text (entmake (list (cons 0 "TEXT") (cons 8 "0") ; Layer 0 (cons 10 pt) ; Insertion point (cons 40 2.0) ; Text height (cons 1 letter) ; Text string (cons 7 "STANDARD") ; Text style ) ) (setq increment (1+ increment)) ) (setq index_copy (1+ index_copy ) increment 0 ) ) ) ) ) ) ; 2. progn ) ; end if (prompt "\nAdding a text values are done!") (princ) )
    1 point
  10. I worked on a LISP for this yesterday at home, still at it today. Copying and scaling in a circle was easy enough, working on trimming everything today when work allows. I usually use AutoCAD Mechanical for this (usually shaft details which I do in Mechanical) or a View in a Viewport in the Layout Tab, but might be handy to not need to open a drawing in AutoCAD Mechanical and just do it in Modelspace Vanilla AutoCAD.
    1 point
  11. Can you describe more about this, part when the numerical prefix or suffix are changable?
    1 point
  12. The system variable that you require for this task is AUTOSNAP. This system variable is bit-coded, with the following bit codes exhibiting the associated behaviour as described below: 0 Turns off the AutoSnap marker, tooltips, and magnet. Also turns off polar tracking, object snap tracking, and tooltips for polar tracking, object snap tracking, and Ortho mode 1 Turns on the AutoSnap marker 2 Turns on the AutoSnap tooltips 4 Turns on the AutoSnap magnet 8 Turns on polar tracking 16 Turns on object snap tracking 32 Turns on tooltips for polar tracking, object snap tracking, and Ortho mode As such, to control Polar tracking, you'll need to flip bit 8. Since we're working with a bit-coded integer, it is easiest & most appropriate to manipulate this value using the various bitwise functions defined in AutoLISP: boole, logand, logior, ~. Below are a few examples demonstrating how to accomplish this: Turn on Polar Tracking: (setvar 'autosnap (logior 8 (getvar 'autosnap))) Note that the above is still applicable even when polar tracking is already turned on, since logior implements inclusive OR logic (hence the name "ior"): _$ (logior 8 39) 47 _$ (logior 8 47) 47 Check if Polar Tracking is enabled: _$ (= 8 (logand 8 (getvar 'autosnap))) T Turn off Polar Tracking: (setvar 'autosnap (logand (~ 8) (getvar 'autosnap))) Note that the above is performing a bitwise AND against the 1's-complement of 8 which is 31-bits set to 1 with bit 8 set to 0, that is, returning all bits except bit 8: _$ (int->bin (~ 8)) "11111111111111111111111111110111" 11111111111111111111111111110111 = (~ 8) = -9 00000000000000000000000000101111 = 47 ---------------------------------- LOGAND 00000000000000000000000000100111 = 39 Check if Polar Tracking is disabled: _$ (zerop (logand 8 (getvar 'autosnap))) T Toggle Polar Tracking: _$ (setvar 'autosnap (boole 6 8 (getvar 'autosnap))) 47 _$ (setvar 'autosnap (boole 6 8 (getvar 'autosnap))) 39 Here, supplying the first argument of 6 to the boole function results in bitwise XOR logic (exclusive OR): 00000000000000000000000000001000 = 8 00000000000000000000000000101111 = 47 ---------------------------------- XOR 00000000000000000000000000100111 = 39 00000000000000000000000000001000 = 8 00000000000000000000000000100111 = 39 ---------------------------------- XOR 00000000000000000000000000101111 = 47
    1 point
×
×
  • Create New...