All Activity
- Past hour
-
archengsafdar joined the community
- Today
-
Also, if you are using AutoCAD 2024LT or AutoCAD 2024, there is built-in function as I mentioned, and you can use it, and you will get something like this (picture 1). Picture 1. showhtmlmodalwindow
-
Have you looked at using a script ? Basically its a multi line file with extension .SCR, it would be like this. It just executes every line opening and closing dwg files. open DWG1 (load "myfixlisp") Open dwg2 (load "myfixlisp") open dwg3 (load "myfixlisp") Google "script writer" You may be able to pick a directory and write the script, then run it, using a lisp. Lee-mac has a good "get a list of dwgs in a directory".
-
Help me to fix an old viwport grid lisp.
BIGAL replied to mhy3sx's topic in AutoLISP, Visual LISP & DCL
-
You can make a selection set of all your viewports, and loop through them and set to locked. No user interaction. Done via a lisp. Now where did I put it. Also think make a new layout with a matching viewport at scale of a point picked in model space, the locking can be part of that program as suggested previously when making a viewport.
-
What is obvious is that non of the responders probably have a LT2024+. So again to @p7q can you copy this one line to the command line of your LT and let us know if it works. It may only open a web site but may be useful. (command "browser" "https://maps.google.com.au" ) As a part time user of Powershell that may be one way around the API call as does LT allow for "Shell" ie open a bat file. Another test should open Notepad. (command "shell" "Notepad") The more tests you do for us the more we may be able to help.
-
-
ok your writing a file say a CSV file then open in excel, first comment can write direct to Excel no need for a CSV. Second comment is post a sample dwg.
-
benjs1 joined the community
-
sirikorn.sr joined the community
- Yesterday
-
Hi Indeed, any process started from AutoCAD will inherit its privilege level. For example, if AutoCAD opens an instance of Word, that instance will inherit the same privilege level as AutoCAD. However, if a Word instance is already running and AutoCAD starts controlling it, its privilege level might be different. In that case, it might be necessary to check it in order to warn the user. Could your issue be something similar to that? As @mhupp says, there is no direct way to determine this from VLisp. But there are some tricks to achieve it: For example: (defun acadAdmin? (/ arch r ruta ruta1 f sh) (if (findfile (setq ruta1 (strcat (getenv "TEMP") "\\acAdmin.si"))) (vl-file-delete ruta1) ) (if (setq arch (open (setq ruta (strcat (getenv "TEMP") "\\ea.bat")) "w")) (progn (write-line "@echo off net session >nul 2>&1 if %errorlevel% == 0 ( echo SI> \"%temp%\\acAdmin.si\" )" arch ) (close arch) (setq sh (vlax-create-object "WScript.Shell")) (vlax-invoke sh 'Run ruta 0 :vlax-true) (vlax-release-object sh) (vl-file-delete ruta) (if (setq r (findfile ruta1)) (progn (vl-file-delete ruta1) T ) ) ) ) ) This simply writes a .bat that when executed, creates the file "acAdmin.si" only if AutoCAD is running as admin
-
Thank you for the advice . seems this may offer me some help.
-
Optimizing a Streamer's PC Setup for Performance and Quality
oddssatisfy replied to oddssatisfy's topic in Hardware & Operating Systems
thank you for your suggestion -
C. Roberts started following Batch run a lisp program
-
I have a lisp program that I use to setup things on a dxf file and it then saves it to .dwg. I would like to add to the program to be able to batch run it on all the .dxf files that are in the folder of the open .dxf file that the lisp is initiated from. This would need to be also able to run on just the single drawing as well. I would like help on creating the batch/single drawing code. This needs to be able to run on AutoCAD LT 2024 or newer. Can this be done all through lisp or does the lisp need to create scripts to run? Thank for the help!! I'll insert my existing code that works on single dxf's here: ;;; BBSSHOP.LSP ;;; ;;; This program sets up drawing variables and performs a series of commands ;;; based on the original script provided. ;; Load the Visual LISP extensions to work with ActiveX (vl-load-com) ;;;------------------------------------------------------------------ ;;; Helper Function to Create a Text Style ;;;------------------------------------------------------------------ (defun create_text_style (tstyle_name font_file txt_hgt /) ;; Added one more "" to answer all prompts from the -STYLE command (command "-STYLE" tstyle_name font_file txt_hgt "" "" "" "" "") (princ (strcat "\nText style '" tstyle_name "' created.")) ) ;;;------------------------------------------------------------------ ;;; Helper Function to Create a Dimension Style ;;; This function is updated to handle optional settings for the new styles. ;;;------------------------------------------------------------------ (defun create_dim_style (dstyle_name tstyle_name arrow_size txt_hgt ext_beyond ext_offset txt_gap /) ;; Set all base dimension style variables first (setvar "DIMZIN" 3) (setvar "DIMTAD" 1) (setvar "DIMTIH" 0) (setvar "DIMLUNIT" 4) (setvar "DIMFRAC" 2) (setvar "DIMRND" 0.0625) (setvar "DIMTMOVE" 2) (setvar "DIMBLK" "_CLOSED") (setvar "DIMLDRBLK" "_CLOSED") (setvar "DIMTXSTY" tstyle_name) (setvar "DIMASZ" arrow_size) (setvar "DIMTXT" txt_hgt) (setvar "DIMEXE" ext_beyond) (setvar "DIMEXO" ext_offset) (setvar "DIMGAP" txt_gap) ;; If creating the alternate style, set the specific overrides. ;; Otherwise, ensure standard settings are applied. (if (wcmatch dstyle_name "*_CONT") (progn (setvar "DIMSD1" 1) ; Suppress Dimension Line 1 (setvar "DIMSE1" 1) ; Suppress Extension Line 1 (setvar "DIMJUST" 2) ; Text horizontal position to 2nd extension line ) (progn (setvar "DIMSD1" 0) ; Ensure Dimension Line 1 is ON for standard styles (setvar "DIMSE1" 0) ; Ensure Extension Line 1 is ON for standard styles (setvar "DIMJUST" 0) ; Ensure text is centered for standard styles ) ) ;; Save all the current DIM... settings into a new style (command "-DIMSTYLE" "SAVE" dstyle_name) (princ (strcat "\nDimension style '" dstyle_name "' created.")) ) ;;;------------------------------------------------------------------ ;;; Helper Function to Create a Multileader Style ;;;------------------------------------------------------------------ (defun create_mleader_style (mlstyle_name setArrowSize setBreakSize setDoglegLength setLandingGap tstyle_name /) ;; Get the dictionary of MLeader styles (setq dict (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")) (setq vDict (vlax-ename->vla-object (cdr (assoc -1 dict)))) ;; Add a new MLeader style object (setq sty (vlax-invoke-method vDict 'AddObject mlstyle_name "AcDbMLeaderStyle")) ;; Set the properties for the new style (vlax-put-property sty 'ArrowSymbol "_Closed") (vlax-put-property sty 'ArrowSize setArrowSize) (vlax-put-property sty 'BreakSize setBreakSize) (vlax-put-property sty 'DoglegLength setDoglegLength) (vlax-put-property sty 'LandingGap setLandingGap) (vlax-put-property sty 'TextLeftAttachmentType 1) (vlax-put-property sty 'TextRightAttachmentType 5) (vlax-put-property sty 'TextStyle tstyle_name) ;; Set multileader style as active (setvar "CMLEADERSTYLE" mlstyle_name) (princ (strcat "\nMultileader style '" mlstyle_name "' created.")) ) ;;;------------------------------------------------------------------ ;;; Main Function: BBSSHOP ;;;------------------------------------------------------------------ (defun c:BBSSHOP () (setvar "SNAPMODE" 0) (setvar "UCSICON" 0) (cond ;; CZEPIECE ((tblsearch "BLOCK" "CZEPIECE") ;; 1. Define style names and sizes (setq text_style "CZE_TEXT") (setq dim_style "CZE_DIM") (setq dim_style_cont (strcat dim_style "_CONT")) (setq ml_style "CZE_ML") ;; 2. Create the text style first (create_text_style text_style ; tstyle_name "SIMPLEX.SHX" ; font_file 0.062 ; txt_hgt ) ;; 3. Create the dimension styles (create_dim_style dim_style ; dstyle_name text_style ; tstyle_name 0.065 ; arrow_size 0.062 ; txt_hgt 0.05 ; ext_beyond 0.4 ; ext_offset 0.021 ; txt_gap ) (create_dim_style dim_style_cont ; dstyle_name text_style ; tstyle_name 0.065 ; arrow_size 0.062 ; txt_hgt 0.05 ; ext_beyond 0.4 ; ext_offset 0.021 ; txt_gap ) ;; Restore the primary dimension style to make it active (command "-DIMSTYLE" "R" dim_style) ;; 4. Create the multileader style (create_mleader_style ml_style ; mlstyle_name 0.065 ; setArrowSize 0.062 ; setBreakSize 0.062 ; setDoglegLength 0.031 ; setLandingGap text_style ; tstyle_name ) ) ;; ASMPIECE ((tblsearch "BLOCK" "ASMPIECE") ;; 1. Define all style names (setq text_style_detail "ASM_TEXT_DETAIL") (setq text_style_bom "ASM_TEXT_BOM") (setq text_style_assy "ASM_TEXT_ASSY") (setq dim_style_detail "ASM_DIM_DETAIL") (setq dim_style_detail_cont (strcat dim_style_detail "_CONT")) (setq dim_style_assy "ASM_DIM_ASSY") (setq dim_style_assy_cont (strcat dim_style_assy "_CONT")) (setq ml_style_detail "ASM_ML_DETAIL") (setq ml_style_assy "ASM_ML_ASSY") ;; 2. Create the 3 text styles (create_text_style text_style_detail "SIMPLEX.SHX" 0.108) (create_text_style text_style_bom "SIMPLEX.SHX" 0.1) (create_text_style text_style_assy "SIMPLEX.SHX" 0.0805) ;; 3. Create the 4 dimension styles (create_dim_style dim_style_detail ; dstyle_name text_style_detail ; tstyle_name 0.0675 ; arrow_size 0.108 ; txt_hgt 0.0675 ; ext_beyond 0.0675 ; ext_offset 0.0365 ; txt_gap ) (create_dim_style dim_style_detail_cont ; dstyle_name text_style_detail ; tstyle_name 0.0675 ; arrow_size 0.108 ; txt_hgt 0.0675 ; ext_beyond 0.0675 ; ext_offset 0.0365 ; txt_gap ) (create_dim_style dim_style_assy ; dstyle_name text_style_assy ; tstyle_name 0.0503 ; arrow_size 0.0805 ; txt_hgt 0.0302 ; ext_beyond 0.2715 ; ext_offset 0.0269 ; txt_gap ) (create_dim_style dim_style_assy_cont ; dstyle_name text_style_assy ; tstyle_name 0.0503 ; arrow_size 0.0805 ; txt_hgt 0.0302 ; ext_beyond 0.2715 ; ext_offset 0.0269 ; txt_gap ) ;; Restore the assembly dimension style to make it active (command "-DIMSTYLE" "R" dim_style_assy) ;; 4. Create the 2 multileader styles (create_mleader_style ml_style_detail ; mlstyle_name 0.0675 ; setArrowSize 0.108 ; setBreakSize 0.108 ; setDoglegLength 0.054 ; setLandingGap text_style_detail ; tstyle_name ) (create_mleader_style ml_style_assy ; mlstyle_name 0.0503 ; setArrowSize 0.0805 ; setBreakSize 0.0805 ; setDoglegLength 0.04025 ; setLandingGap text_style_assy ; tstyle_name ) ) ;; INT_COL ((tblsearch "BLOCK" "INT_COL") ;; 1. Define style names and sizes (setq text_style "INT_TEXT") (setq dim_style "INT_DIM") (setq dim_style_cont (strcat dim_style "_CONT")) (setq ml_style "INT_ML") ;; 2. Create the text style first (create_text_style text_style ; tstyle_name "SIMPLEX.SHX" ; font_file 0.07 ; txt_hgt ) ;; 3. Create the dimension styles (create_dim_style dim_style ; dstyle_name text_style ; tstyle_name 0.065 ; arrow_size 0.07 ; txt_hgt 0.06 ; ext_beyond 0.26 ; ext_offset 0.023 ; txt_gap ) (create_dim_style dim_style_cont ; dstyle_name text_style ; tstyle_name 0.065 ; arrow_size 0.07 ; txt_hgt 0.06 ; ext_beyond 0.26 ; ext_offset 0.023 ; txt_gap ) ;; Restore the primary dimension style to make it active (command "-DIMSTYLE" "R" dim_style) ;; 4. Create the multileader style (create_mleader_style ml_style ; mlstyle_name 0.065 ; setArrowSize 0.07 ; setBreakSize 0.07 ; setDoglegLength 0.035 ; setLandingGap text_style ; tstyle_name ) ) ;; WEBB ((tblsearch "BLOCK" "WEBB") ;; 1. Define style names and sizes (setq text_style "WEB_TEXT") (setq dim_style "WEB_DIM") (setq dim_style_cont (strcat dim_style "_CONT")) ;; 2. Create the text style first (create_text_style text_style ; tstyle_name "SIMPLEX.SHX" ; font_file 0.08 ; txt_hgt ) ;; 3. Create the dimension styles (create_dim_style dim_style ; dstyle_name text_style ; tstyle_name 0.05 ; arrow_size 0.08 ; txt_hgt 0.02 ; ext_beyond 0.06 ; ext_offset 0.02 ; txt_gap ) (create_dim_style dim_style_cont ; dstyle_name text_style ; tstyle_name 0.05 ; arrow_size 0.08 ; txt_hgt 0.02 ; ext_beyond 0.06 ; ext_offset 0.02 ; txt_gap ) ;; Restore the primary dimension style to make it active (command "-DIMSTYLE" "R" dim_style) ) ) ;; Run AutoCAD Commands (command "-LINETYPE" "SET" "BYLAYER" "") (command "-INSERT" "PART_PAGE_SETUP.dwg" "0,0" "1" "1" "0") (command "-PURGE" "B" "*" "N") (command "-PURGE" "LA" "*" "N") (setvar "FILEDIA" 0) (command "-PLOT" "n" "Layout1" "B-SIZE PDF" "" "" "y" "n") (setvar "FILEDIA" 1) ;; --- START: Copy Layout from Template --- (princ "\nImporting layout from template...") (setq new_layout_name (vl-filename-base (getvar "DWGNAME"))) (setq template_path (findfile "PART_PAGE_SETUP.dwg")) (if template_path (progn (princ (strcat "\nTemplate found: " template_path)) ;; Switch to Model tab to prevent deleting the active layout (setvar "CTAB" "Model") ;; --- CORRECTED: Use (layoutlist) to check for existing layouts --- (setq layout_list (layoutlist)) ;; 1. Delete the target layout name if it already exists (to overwrite). (if (member new_layout_name layout_list) (command "-LAYOUT" "D" new_layout_name) ) ;; 2. Delete the *source* layout name if it exists in the current drawing. (if (member "PART_PAGE_SETUP" layout_list) (command "-LAYOUT" "D" "PART_PAGE_SETUP") ) ;; 3. Import the layout from the template. (command "-LAYOUT" "T" template_path "PART_PAGE_SETUP") ;; 4. Rename the newly imported layout. (command "-LAYOUT" "R" "PART_PAGE_SETUP" new_layout_name) ;; 5. After the new layout is secure, delete the original "Layout1". (if (and (/= (strcase "Layout1") (strcase new_layout_name)) (member "Layout1" (layoutlist)) ; Check updated list ) (command "-LAYOUT" "D" "Layout1") ) (princ (strcat "\nSuccessfully created layout: " new_layout_name)) ) (princ "\nERROR: Could not find 'PART_PAGE_SETUP.dwg' in AutoCAD's support file paths.") ) ;; --- END: Copy Layout from Template --- ;; Finalize and Clean Up (command "ZOOM" "EXTENTS") (command "REGEN") (command "SAVEAS" "" "") (princ "\nBBSSHOP routine complete.") (princ) )
-
Help me to fix an old viwport grid lisp.
mhy3sx replied to mhy3sx's topic in AutoLISP, Visual LISP & DCL
so you said to add support viewports and polylines? -
Pamir77 joined the community
-
Just type PS at the command line and hit Enter. That will switch you to paper space and then you can zoom out.
-
Help me to fix an old viwport grid lisp.
BlackBox replied to mhy3sx's topic in AutoLISP, Visual LISP & DCL
It already supports that. Viewport (1) just means that there's 1 object linked... click the dropdown and you'll see the Viewport and Polyline. The code only allows selection of "VIEWPORT", so when you select it on screen, the Polyline is ignored. -
Help me to fix an old viwport grid lisp.
mhy3sx replied to mhy3sx's topic in AutoLISP, Visual LISP & DCL
Is any way the code to support Viewport (1) ? Thanks -
Alan Baker joined the community
-
But how do you lock into paper space if you have zoomed in and cannot find the viewport edge to click on it? I have made a lot of changes and thought paper space was locked so now I cannot zoom out - the drawing is not locked?
-
BlackBox started following Help me to fix an old viwport grid lisp. and Detecting privileges with Lisp
-
Post your code. Those that know how do this may feel that it's sus to 'check privileges to see if a task can be carried out', based on what little info you've posted, FWIW.
-
Help me to fix an old viwport grid lisp.
BlackBox replied to mhy3sx's topic in AutoLISP, Visual LISP & DCL
It says Viewport (1) because you've created a Viewport by object (Polyline), so they're linked. Your code works fine here and only seems to error when the Viewport is on a locked layer, and the linked Polyline is not... but I am unable to produce the 'no viewport selected' you mentioned. -
Thanks for the answers. I’ve done some research and found that all processes invoked from AutoCAD inherit the same privilege level. Therefore, it may be enough to know the privilege level with which AutoCAD is running (although ideally, it should work to check any process). I need this to predict whether a task that requires privileges can be carried out or not
-
Hi , I use this lisp for years but I have a problem. When I Polyline on layout and select to create viewport from object , when I select the new viewport in properties say VIewport (1) and not Viewport. Then when I run the attach lisp to create the grid on viewport say that no viewport selected. Can any one help me to fix this ? Thanks Surveygridneg.lsp
-
Steven P started following Detecting privileges with Lisp
-
what is your end goal with detecting privileges / admin access? There might be other ways to do what you want of course.
-
Good clarification. From the link I posted. TIP 14007
-
mhupp started following Detecting privileges with Lisp
-
like lido said In AutoLISP, cannot directly check for Windows Admin privileges, because AutoLISP is sandboxed within AutoCAD and cant see those types of windows things. tho I wouldn't try and copy files into sys folder. because if you do (admin rights) you would have a bunch of junk files in there. then the next step is to delete the copied file. that is a hop skip and a jump away from delete something needed. I suggest using cmd prompt. it can list admin users and you can output that to a txt file that autocad can then read. if user name true. something like "net localusers administrators > c:\admintest.txt"
-
Mammadov joined the community
-
lido started following Detecting privileges with Lisp
-
I think you could do this by testing whether an operation that requires administrative rights can be performed. For example, copying a file to the Windows\System folder.
-
maryfischer joined the community
-
sander joined the community
- Last week
-
@BlackBox I sent you a PM to keep this thread related to its aim.