Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/26/2025 in Posts

  1. And, after a moment of reflection, there's another, less invasive way. I'm just winging it here because I haven't done it before, but I think it should be possible to create an embedded HTTP server in PowerShell. You could write the necessary script to do this from Lisp and run it by calling PowerShell, giving it the necessary instructions to listen to a specific port and call AutoCAD via "sendCommand." But this is such an interesting topic that it might deserve its own thread. I'll leave it for the forum administrators to consider.
    1 point
  2. Thinking a bit about the idea of being able to handle URL requests, it occurs to me that this could be done by creating a command ("c:genKeys", for example) that asks for the number of requests to handle and starts a "while" loop. In this "while" loop, it will look for any changes in a predetermined file (which will be where your remote Lisp writes the hard drive or motherboard ID). For each change it detects, it will subtract 1 from the number of requests you indicated at the beginning, and when that subtraction reaches 0, the command will end. This is the only way I can think of to do this without using a language other than Lisp.
    1 point
  3. All of this must be planned for in your Lisp code. It will only do what you tell it to.
    1 point
  4. Are you talking about turning your AutoCAD installation into a server that handles URL requests? That's not possible with VLisp. With Python, it might be. @Danielm103 might have some interesting suggestions for you. In VLisp, the only possibility would be for your PC — from which you're going to provide the registration code — to run a while loop checking for updates in a predefined file that logs the requests coming from your program on other PCs.
    1 point
  5. Are you talking about turning your AutoCAD installation into a server that handles URL requests? That's not possible with VLisp. With Python, it might be. @DanielM103 might have some interesting suggestions for you. In VLisp, the only possibility would be for your PC — from which you're going to provide the registration code — to run a while loop checking for updates in a predefined file that logs the requests coming from your program on other PCs.
    1 point
  6. Something like this in the acadLTdoc.lsp ;;; acadLTdoc.lsp placed on network folder (setq lispFolder "Z:/Shared/LISP/") ; Change this to your network share path ; Load each LISP file (load (strcat lispFolder "routine1.lsp")) (load (strcat lispFolder "routine2.lsp")) ; Add as needed Then you need to updated each users Support File Search Path and Trusted Folders to include the folder for acadLTdoc.lsp Powershell $baseKey = "HKCU:\Software\Autodesk\AutoCAD LT\R24\ACADLT-1001:409\Profiles\<<Unnamed Profile>>\Preferences" $newPath = "Z:\Shared\CAD\LISP" # Update Support Path $supportPath = Get-ItemProperty -Path $baseKey -Name SupportPath if ($supportPath.SupportPath -notlike "*$newPath*") { $updatedSupport = $supportPath.SupportPath + ";" + $newPath Set-ItemProperty -Path $baseKey -Name SupportPath -Value $updatedSupport } # Update Trusted Paths $trustedPaths = Get-ItemProperty -Path $baseKey -Name TrustedPaths if ($trustedPaths.TrustedPaths -notlike "*$newPath*") { $updatedTrusted = $trustedPaths.TrustedPaths + ";" + $newPath Set-ItemProperty -Path $baseKey -Name TrustedPaths -Value $updatedTrusted } Or You can update profiles. Configure AutoCAD LT on one machine with the correct paths> Export the profile using the OPTIONS > Profiles tab > Export. Distribute the .arg file and use... "C:\Program Files\Autodesk\AutoCAD LT 2024\acadlt.exe" /p "MyCustomProfile.arg" Or If preferred you can go direct to Windows registry. (I believe this is correct, but double check) yor IT should know how to do it. Reg value: SupportPath Type: REG_SZ Reg value: TrustedPaths Type: REG_SZ C:\Program Files\Autodesk\AutoCAD LT 2024\Support;Z:\Shared\CAD\LISP Or update profiles like this. HKEY_CURRENT_USER\Software\Autodesk\AutoCAD LT\R24\ACADLT-<lang_code>:<product_code>\Profiles\<YourProfileName>\Preferences Your IT may have a deployment software, something above should be what they need for that as well.
    1 point
  7. You can also use the line direction left will be -ve right is positive. The way to use this is to pick near an end that implies the direction then do offset point. Here is an example of working out direction. Swaps start & end if required. Then as suggested use the angle of start - end + pi/2. (setq ent (entsel "\nPIck object near end ")) (setq pt (cadr ent)) (setq obj2 (vlax-ename->vla-object (car ent))) (setq start (vlax-curve-getstartPoint obj2)) (setq end (vlax-curve-getendPoint obj2)) (setq d1 (distance pt start)) (setq d2 (distance pt end)) (if (> d1 d2) (setq tmp start start end end tmp )
    1 point
  8. This will write direct to excel dwg names, just pick a dwg in correct directory. Do not have Excel open as it will be opened. Big thanks to Lee Mac for the get dwg names. ; https://www.cadtutor.net/forum/topic/98263-extracting-block-data-to-a-report/page/6/ (defun c:dwgs2excel ( / direc filen files) ;; Directory Files - Lee Mac ;; Retrieves all files of a specified filetype residing in a directory (and subdirectories) ;; dir - [str] Root directory for which to return filenames ;; typ - [str] Optional filetype filter (DOS pattern) *.dwg ;; sub - [bol] If T, subdirectories of the root directory are included ;; Returns: [lst] List of files matching the filetype criteria, else nil if none are found (defun LM:directoryfiles ( dir typ sub ) (setq dir (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir))) (append (mapcar '(lambda ( x ) (strcat dir "\\" x)) (vl-directory-files dir typ 1)) (if sub (apply 'append (mapcar '(lambda ( x ) (if (not (wcmatch x "`.,`.`.")) (LM:directoryfiles (strcat dir "\\" x) typ sub) ) ) (vl-directory-files dir nil -1) ) ) ) ) ) ;; Thanks to fixo ;; ;; = Set Excel cell text = ;; ;; ;; (defun xlsetcelltext ( row column text) (setq cells (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Cells")) (vl-catch-all-apply 'vlax-put-property (list cells 'Item row column (vlax-make-variant (vl-princ-to-string text) vlax-vbstring)) ) ) (setq myxl (vl-catch-all-apply 'vlax-get-or-create-object '("Excel.Application"))) (vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add) (vla-put-visible myXL :vlax-true) (vlax-put-property myxl 'ScreenUpdating :vlax-true) (vlax-put-property myXL 'DisplayAlerts :vlax-true) (setq direc (VL-FILENAME-DIRECTORY (getfiled "Select dwg File for top directory " "" "dwg" 16))) (initget 1 "Yes No") (setq Yesno (getkword "\nDo you want subdirectories [Yes No] ")) (if (= yesno "Yes") (setq files (LM:directoryfiles direc "*.dwg" T)) (setq files (LM:directoryfiles direc "*.dwg" nil)) ) (setq row 0) (foreach filen Files (xlsetcelltext (setq row (1+ row)) 1 filen) ) (princ) )
    1 point
  9. My LISP and ClipIt work on nested blocks. I also noticed that the circle in your example drawing was from AutoCAD Mechanical. If you have something that the LISP isn't working on, please post the drawing here so I can see about a fix. I am doing more work on this, specifically some Labelling options. But for now I just have the tangent lines working and made it an option as well as the single line. Let me know how this version is working. ;;; Creates a circular detail clip from a block reference. Copies, scales, and trims to scaled circle (connected by line(s)). ;;; ;;; https://www.cadtutor.net/forum/topic/98334-detail-circle-in-ms/page/3/#findComment-674386 ;;; ;;;************************************************************************************************| ;;; | ;;; By SLW210 (a.k.a. Steve Wilson) | ;;; | ;;; MSCirClip_1.0.lsp | ;;; | ;;; Uses the Express Tool ClipIt manually (maybe this will be automated at a later time). | ;;; At the prompt-Select the detail circle then select the copied and scaled block. | ;;; At Enter maximum allowable error distance for resolution of arc segments. | ;;; I used 1 and it seems good (smaller is more segments) (see Clipit in Express Tools help). | ;;; | ;;;************************************************************************************************| ;;; ClipIt creates a pseudo circle of polylines, the connector line will most likely have a gap. | ;;; | ;;; Added option to delete the detail circle or keep it. | ;;; | ;;; Added option to use a single connector or two tangent lines | ;;; | ;;; | ;;;************************************************************************************************| ;;;************************************************************************************************| ;;; >>> Lee Mac Trigonometric Functions <<< | ;;; | ;;; Tangent - Lee Mac | ;;; Args: x - real | (defun tan (x) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) ;;; | ;;; ArcCosine - Lee Mac | ;;; Args: -1 <= x <= 1 | (defun acos (x) (if (<= -1.0 x 1.0) (atan (sqrt (- 1.0 (* x x))) x) ) ) ;;; | ;;;************************************************************************************************| (defun c:MSCIRCLIP (/ ent cen rad newPt scaleFactor newRad scaledBlock detailCircle c1 c2 r1 r2 dx dy d ang3 theta ang1 ang2 t1a t1b t2a t2b lineOption vec len dir pt1 pt2 suffix txtHeight txtPoint txtStr delCircle layerTable detailLayer ) (vl-load-com) (prompt "\n--- MODELSPACE DETAIL VIEW WITH CLIPIT ---\n") ;; Ensure DETAIL layer exists and set current (setq detailLayer "DETAIL") (setq layerTable (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) (if (null (tblsearch "LAYER" detailLayer)) (vla-add layerTable detailLayer) ) (setvar 'CLAYER detailLayer) ;; Select block reference (setq ent (car (entsel "\nSelect block reference to detail: "))) (if (not (and ent (= (cdr (assoc 0 (entget ent))) "INSERT"))) (progn (prompt "\nNot a valid block reference.") (exit)) ) ;; Original detail circle (setq cen (getpoint "\nSpecify center of detail circle: ")) (setq rad (getdist cen "\nSpecify radius of detail circle: ")) (entmakex (list '(0 . "CIRCLE") (cons 10 cen) (cons 40 rad) (cons 62 1) (cons 8 detailLayer) ) ) ;; Detail view placement (setq newPt (getpoint "\nSpecify center point for detail view: ")) (initget 7) (setq scaleFactor (getreal "\nEnter detail scale factor (e.g. 2): ")) (setq newRad (* rad scaleFactor)) ;; Copy and scale block (command "COPY" ent "" cen newPt) (setq scaledBlock (entlast)) (command "SCALE" scaledBlock "" newPt scaleFactor) ;; Create clipping circle (temporary) (setq detailCircle (entmakex (list '(0 . "CIRCLE") (cons 10 newPt) (cons 40 newRad) (cons 62 1) (cons 8 detailLayer) ) ) ) ;; Run CLIPIT (prompt "\n>>> Run CLIPIT: Select the detail circle and the new (scaled) block.\n" ) (C:CLIPIT) ;; Connector line (initget "Single Tangents") (setq lineOption (getkword "\nDraw [Single/Tangents] connector line(s)? <Single>: " ) ) (if (null lineOption) (setq lineOption "Single") ) (if (eq lineOption "Single") (progn (setq vec (mapcar '- newPt cen)) (setq len (distance cen newPt)) (setq dir (mapcar '/ vec (list len len len))) (setq pt1 (mapcar '+ cen (mapcar '* dir (list rad rad rad)))) (setq pt2 (mapcar '- newPt (mapcar '* dir (list newRad newRad newRad)) ) ) (entmakex (list '(0 . "LINE") (cons 10 pt1) (cons 11 pt2) (cons 62 3) (cons 8 detailLayer) ) ) ) ;; Tangents (progn (setq c1 cen r1 rad c2 newPt r2 newRad ) (setq dx (- (car c2) (car c1))) (setq dy (- (cadr c2) (cadr c1))) (setq d (sqrt (+ (* dx dx) (* dy dy)))) (if (<= d (abs (- r1 r2))) (prompt "\nCircles too close — no external tangents.\n") (progn (setq ang3 (atan dy dx)) (setq theta (acos (/ (- r1 r2) d))) (setq ang1 (- ang3 theta)) (setq ang2 (+ ang3 theta)) (setq t1a (polar c1 ang1 r1)) (setq t1b (polar c2 ang1 r2)) (setq t2a (polar c1 ang2 r1)) (setq t2b (polar c2 ang2 r2)) (entmakex (list '(0 . "LINE") (cons 10 t1a) (cons 11 t1b) (cons 62 3) (cons 8 detailLayer) ) ) (entmakex (list '(0 . "LINE") (cons 10 t2a) (cons 11 t2b) (cons 62 3) (cons 8 detailLayer) ) ) ) ) ) ) ;; Prompt for deletion (initget "Yes No") (setq delCircle (getkword "\nDelete the scaled detail circle? [Yes/No] <No>: " ) ) (if (eq delCircle "Yes") (progn (if (and detailCircle (entget detailCircle)) (entdel detailCircle) ) ) ) (prompt "\nDetail view created with ClipIt.\n") (princ) )
    1 point
  10. @GLAVCVS has mad e a good suggestion, In your check code you can do a IF with a "OR" with the list of keys, or a cond so can have multiple keys but only one program required. In your lisps you just need a (load "mysecuritylisp.lsp) as 1st line it would be set up to auto run. You would give it a name similar to your other lisps so it does not appear to be the check lisp. You can pad it out with junk so long as it has a ";" as 1st character so the lisp file size is not obvious. You only need to run once by checking has it been loaded. (if (not mysecurtiycheck)(load "ASDFGH.lsp")) ; the defun name in the security lisp would be in this case mysecurtiycheck. NO C:.
    1 point
  11. Maybe I finally understood your question: If what you mean is that you were planning to write a unique registration code in your Lisp to register your application on any PC, I don't think it's a good idea. The right thing to do is design an algorithm to generate a key from the serial number of the hard drive or motherboard (whichever you prefer). From that algorithm, you'll need to write a function that converts the serial number into a key. And that key will be the one you'll need to register when you first install your application, and it will be checked every time it's loaded thereafter. Therefore, your algorithm will create a different key for each PC.
    1 point
  12. Ok one of the things you can do is using old fashioned DOS, yes us oldy's know what that is, but you can write one checkuser.lsp program that has the hidden code in it. Ok from windows cmd you can run a bat file, yeah old DOS. Repeat for every lisp. Copy checkuser.lsp+mylispprogram1.lsp c:/compile/mylispprogram.lsp You do this in a bat file for every lisp program so it appends your check code to your lisp programs. Saving as a copy is a good idea. You can then use this to make FAS files of the new lisp. ; must have vlide open to work (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "Vlide") (setq loads (list ""xxx3d pts on face 4" "xxxblock atts invisible" "xxxChange client logos-3" "xxxClose plines" "xxxCogo Label_C" ) ) (setq loc1 "C:\\XXX-CAD-TOOLS\\") ;;change dirs to where ever you want them found (setq loc2 "D:\\XXX\\compile\\") ;;change dirs to where ever you want them saved (foreach lisp loads (vlisp-compile 'st (strcat loc1 lisp ".lsp") (strcat loc2 lisp ".fas")) )
    1 point
  13. I don't think I understand exactly what you mean. Can you explain that a little more?
    1 point
  14. But if the registration code is invalid, all symbols created during application loading must be set to 'nil'.
    1 point
  15. Hi I suppose you should compile the code. Do you have functions to obtain hardware serial numbers? If so, one implementation of the code could be to group the payment functions under a main function that only runs if a key you created exists in the Windows registry. Your code should create that key when the user enters a valid registration code. Another option is to save the registration code in a file. Or in both. If, when your application loads, it finds the key and it's correct, then it would load the defun with all the protected code.
    1 point
  16. The only reliable way I know to align the stretch box is to turn the model by changing the UCS. Use the PLAN command to redraw the model in the current UCS. There's probably a way to do that without a Zoom Extents in the bargain (Dview Twist?). When you're through, change the UCS back to World and run PLAN again. A bit of research says Dview may turn the camera without changing the UCS. Even better. You can change back to the normal view when you finish your stretch, no UCS change or PLAN necessary.
    1 point
×
×
  • Create New...