Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Scoutr4

    Why is vla-insert different?

    I agree with what you said. (setq theblock (vla-InsertBlock mspace ip item xscale yscale zscale rot)) Editing the code like this fixed it. Thanks .
  3. I think Steven is right , this is about redefining or not. When you insert a block without path , AutoCad uses the block definition allready present in active drawing. If you put a path to it , AutoCad will overwrite current block definition with the one on file. So , if you insert block for the first time , then edit it and after that insert the one from file , your edited definition will be overwritten again. Standard / classic / basic AutoCad behaviour.
  4. Today
  5. Scoutr4

    Why is vla-insert different?

    I prepared a block dwg file and a example dwg file. And of course the lsp file for comparison. I deleted the inner part of the block in the example dwg file. Without deleting this block, add the second block using the commands in the lsp file. Note 1 : link for vla-insertblock >> https://www.afralisp.net/archive/methods/lista/insertblock_method.htm (I just changed the item line to select it) Note 2 : After using the "al-insertblock" command in AutoCAD, run the regen command. BLOCK.dwg EXAMPLE.dwg EXAMPLE.lsp
  6. Steven P

    Why is vla-insert different?

    Are you able to post a copy of the LISP so we can see what is happening? Sounds like your (command method is referring to the source file and the (vla- method is referring to your working file
  7. Hi everyone, I encountered a problem yesterday. I have a Block.dwg file. I call the Block.dwg file into the A.dwg file and make edits within Block. After that, I run lisp. At this point, I encounter the following error. When I insert the same Block again If I insert it with (command "-insert"). It is based on the block in A.dwg and the block I insert looks like it. If I use the (vla-insertblock) function, it moves according to the inserted block and the blocks in A.dwg look like the block I inserted. What is the reason?
  8. Hi @BIGAL. I’ve taken a look at TriangV0.6.7.lsp but one of the most important functions, c:Prof, doesn’t seem to work properly. I can’t manage to find correspondence between the intersection points of the selected line and the 3DFACEs with what they should be in reality. Has the correct functioning of this command been proven? PS: SOLVED
  9. O mine is the other way around in that the viewport has to be existing in paperspace already with the sacle you want. ;;----------------------------------------------------------------------------;; ;; Creates Viewport outline and moves it to Model space (defun C:VP2M (/ SS vp elist MiscOn cen c40 c41 LL UR) (if (setq SS (ssget "_X" (list '(0 . "viewport") (cons 410 (getvar 'ctab))))) (foreach vp (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq elist (entget vp)) (if (> (cdr (assoc '69 elist)) 1) ; skip display viewport (progn (if (= (cdr (assoc '68 elist)) 0) ; is viewport active? (progn (setq MiscOn 'NO) (vl-cmdf "._Mview" "_on" "_si" vp) ; activate viewport ) (setq MiscOn 'YES) ) (setq cen (cdr (assoc '10 elist)) c40 (cdr (assoc '40 elist)) ;length c41 (cdr (assoc '41 elist)) ;width LL (list (- (car cen) (/ c40 2)) (- (cadr cen) (/ c41 2))) UR (list (+ (car cen) (/ c40 2)) (+ (cadr cen) (/ c41 2))) ) (vl-cmdf "_.Pspace") (vl-cmdf "_.Rectangle" LL UR) (vl-cmdf "_.Chspace" "_Last" "") (vl-cmdf "_.Pspace") (if (eq MiscOn 'NO) (vl-cmdf "_.Mview" "_off" "_si" vp) ; deactivate viewport ) ) ) ) ) ;(setvar 'Tilemode 1) ;switch to model space (princ) )
  10. Yesterday
  11. Like @mhupp I have a couple of make layouts I tend to use this front end which matches a user's title blocks. You can make multiple in one go using 2 different methods or pick a central point. It is two separate functions as you can check the rectangs 1st then make the layouts. Happy to discuss further.
  12. leonucadomi

    Help to modify routine lsp viewports...

    THANKS MASTER
  13. I have a simpler version kicking around at home that ill post later tonight.
  14. mhupp

    add new scale to list...

    oops forgot atoi to set X as an integer. in VBA you can just do math with strings if they are numbers "80" * 5 works the same as 80 * 5. not so much in lisp.
  15. After many months of avoiding this issue when I switched offices. I found out this happens when linetypes are created with .shp files required. If you have an issue where the linetyepes show incorrectly please just do the following to fix. 1. Type "OPTIONS" 2. Go to FILES tab 3. Support File folder, and navigate to the file that holds your fonts files and move it to the top of the list. 4. Finally, close cad and reopen. The hierarchy of the support files a crucial to what it loads and displays in cad. It will ignore the file needed if it is not prioritized in the support file folder correctly. You are welcome
  16. hello : I found a good routine that I really like but I would like it to skip the last two steps. select areas in the model space and create the same number of viewports in the paperspace I want that when the viewports are finished being created, the routine ends and it no longer asks me if I want to return to the model or if I want to make more viewports. some help please. here code: ; NVM creates mspace vports ; Modified: ; 1. Vport layout placement is at lower left corner ; 2. Default setting to switch back to Model vs staying in Layout ; 3. Layout selection defaults to previous selection ; 4. Offers option to select multiple Model views ; 5. Offers dialog selection on scales based on ScalelistEdit ; 6. NVM loops until Esc or Enter during first point of view selection ; OP: ; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-multiple-viewport/m-p/12728443#M464938 (defun c:NVM (/ *error* _RestoreView _GetScaleProp ans count ct doc ll vpscl vpsclp mp p1 p2 ptlst res sc sci scitmp sl tmp vc vp vpdoc vpp vs ) (vl-load-com) (defun *error* (Msg) (princ "Error: ") (princ Msg) (if ct (_RestoreView)) (princ) ) (defun _RestoreView () (setvar "ctab" ct) (vla-ZoomCenter (vlax-Get-Acad-Object) (vlax-3d-Point (trans vc 1 0)) vs) ) ; _GetScaleProp returns list of scalelist name assoc with paper units & drawing units ; modified from: ; https://forums.augi.com/showthread.php?107333-Using-vlisp-to-access-scales-list (defun _GetScaleProp (/ csobj ent entnm index scaleDict scaleDictName scaleObject scllst sclnam unidwg unippr) (setq scaleDict (dictsearch (namedobjdict) "ACAD_SCALELIST")) (setq scaleDictName (cdar scaleDict)) (setq csobj (vlax-ename->vla-object scaleDictName)) (setq index 0) (repeat (vla-get-count csobj) ; loop through all scalelist names (setq scaleObject (vlax-invoke-method csobj 'item index)) (setq entnm (vlax-vla-object->ename scaleObject)) ; convert from obj to entity (setq ent (entget entnm)) ; get entity data (setq sclnam (cdr(assoc 300 ent)) ; scalelist name car itm unippr (cdr(assoc 140 ent)) ; paper units cadr itm unidwg (cdr(assoc 141 ent)) ; drawing units caddr itm scllst (append (list(cons sclnam (list unippr unidwg))) scllst) index (+ index 1) ) ) ; repeat (setq scllst (append scllst (list (list "User" 1.0 1.0)))) ; add user scale (reverse scllst) ) ; (if (/= (getvar "cvport") 1) ; add (progn (setq ; set Model defaults doc (vla-get-ActiveDocument (vlax-get-acad-object)) ct (getvar "ctab") vs (getvar "viewsize") vc (getvar "viewctr") ; start loop p1 T count 0 ; view count vpsclp (_GetScaleProp) ; get scalelist property vpscl (mapcar '(lambda (x) (car x)) vpsclp) ; create list of just first item in assoc pair for list box ll ; build layout list (vlax-for % (vla-get-layouts doc) (setq res (cons (list (vla-get-name %) % (vla-get-TabOrder %) ) res ) ) ) ll (cdr (vl-sort ll '(lambda (a b) (< (last a) (last b)) ) ) ) ) ; setq ; start loop (while p1 (setq ptlst '() count 0) ; reset count & layout list (while p1 ; (if (and (setq p1 (getpoint "\nSelect first point of view or Enter to Exit: ")) (setq p2 (getcorner p1 "\nSelect second point of view: ")) ) (progn ; build list of view points (setq ptlst (append ptlst (list (cons p1 (list p2))))) ; show # of views selected (if(zerop count) (princ (strcat "\n" (itoa (setq count (1+ count))) " View Selected...")) (princ (strcat "\n" (itoa (setq count (1+ count))) " Views Selected...")) ) ) ) ; if ) ; while (if ptlst ; if list of view points (progn ; (princ (strcat"\n" (itoa (length ptlst)) " Views Selected...")) ; add scale selection dialog (if(not sci) (if (not(setq sci (vl-position "1:50" vpscl))) ; select 1:50 as default (setq sci 1) ; else set 2nd item as default ) ) (if (setq scitmp (cd:DCL_StdListDialog vpscl sci "Viewport Scale" "Select Scale:" 40 15 2 nil T T)) (if (eq "User" (nth scitmp vpscl))(setq scitmp nil)(setq sci scitmp)) ) (if scitmp ; then get scale = 3rd item in the prop list (setq sc (fix(caddr(nth sci vpsclp)))) ; else type in scale (setq sc (cond ( (getint (strcat "\nWhat is Viewport Scale 1: <" (itoa (setq sc (cond (sc) (50)))) ">: " ) ) ) ( sc ) ) ) ) ; if ; add highlight of previous layout item selection (if(not sl)(setq sl 0)) (if (setq sl (cd:DCL_StdListDialog (mapcar ' car ll) sl "NewViewport" "Select layout:" 40 15 2 nil T T)) ; (progn (setvar "ctab" (car (nth sl ll))) (vla-put-MSpace doc :vlax-false) ; cycle through all selected view points (setq count 1) (foreach itm ptlst (setq p1 (car itm) p2 (cadr itm) ) ; (if (setq vpp (getpoint (strcat "\nSelect Point for " (itoa count) " of " (itoa (length ptlst)) " Viewports: "))) (progn (if (< (car (trans p2 1 0)) (car (trans p1 1 0)) ) (setq tmp p1 p1 p2 p2 tmp) ) (setq mp (list (/ (+ (car p1) (car p2)) 2) (/ (+ (cadr p1) (cadr p2)) 2) 0.0 ) ) (setq vpdoc (vla-get-PaperSpace doc) vp (vla-AddPViewport vpdoc ; move vport so placement point is at lower left corner ; (vlax-3d-point vpp) (vlax-3d-point (list (+ (car vpp) (/ (abs (/ (- (car p2) (car p1)) sc)) 2) ) (+ (cadr vpp)(/ (abs (/ (- (cadr p2) (cadr p1)) sc)) 2) ) 0.0 ) ) ; (abs (/ (- (car p2) (car p1)) sc)) (abs (/ (- (cadr p2) (cadr p1)) sc)) ) ) (vla-display vp :vlax-true) (vla-put-MSpace doc :vlax-true) (vla-put-ActivePViewport doc vp) (vla-ZoomCenter (vlax-get-acad-object) (vlax-3d-point mp) 1.0 ) (vla-put-CustomScale vp (/ 1. sc)) (vla-put-MSpace doc :vlax-false) (vla-put-DisplayLocked vp :vlax-true) ) (progn (princ "\n** Invalid Point ** ") (if ct (_RestoreView)) ) ) ; (setq count (1+ count)) ) ; foreach ; ) ; progn (princ "\n** Layout not selected ** ") ) ; set default (if(not *ans*)(setq *ans* "Yes")) ; (initget "Yes No") (setq ans (cond ; ( (getkword "\nBack to model space [Yes/No] <No>: ") ) ( (getkword (strcat "\nBack to model space [Yes/No] <" *ans* ">: ")) ) ( *ans* ) ; ( "No" ) ) ) ; reset default (setq *ans* ans) ; (if (= ans "Yes") (_RestoreView)) ; ) ; progn ptlist (princ "\n** Invalid Point ** ") ) ; if ; ) ; while ) ; progn ; add loop end (princ "\nStart Program in Model Space ") ) (princ) ) ; defun NVM ; =========================================================================================== ; ; Okno dialogowe z lista (list_box) / Dialog control with list (list_box) ; ; Data [list] - lista do wyswietlenia / list to display ; ; Pos [INT] - pozycja poczatkowa na liscie / select list position ; ; Title [STR/nil] - tytul okna / window title ; ; ListTitle [STR/nil] - tytul list_box / list_box title ; ; Width [INT] - szerokosc / width ; ; Height [INT] - wysokosc / height ; ; Btns [0/1/2] - [cancel/ok/ok_cancel] przyciski / buttons ; ; MSelect [T/nil] - dopuszczenie multiple_select / allow multiple select ; ; DPos [T/nil] - zapamietanie pozycji okna / save window position ; ; DblClick [T/nil] - podwojny klik (wykluczone Cancel) / double click (not for Cancel) ; ; ------------------------------------------------------------------------------------------- ; ; Zwraca / Return: ; ; nil = nic nie wybrano (anulowano) / nothing was selected (canceled) ; ; INT = wybrano jedna pozycje / one position selected | MSelect = nil ; ; LIST = wybrano kilka pozycji / few positions selected | MSelect = T ; ; ------------------------------------------------------------------------------------------- ; ; (cd:DCL_StdListDialog '("A" "B" "C") 0 "Title" "ListTitle:" 40 15 2 nil T nil) ; ; =========================================================================================== ; (defun cd:DCL_StdListDialog (Data Pos Title ListTitle Width Height Btns MSelect DPos DblClk / f tmp dc res) (if (not DPos) (setq *cd-TempDlgPosition* (list -1 -1))) (cond ( (not (and (setq f (open (setq tmp (vl-FileName-MkTemp nil nil ".dcl")) "w" ) ) (foreach % (list "StdListDialog:dialog{" (strcat "label=\"" (if Title (strcat Title "\";") "\"\";") ) ":list_box{key=\"list\";" (if ListTitle (strcat "label=\"" ListTitle "\";")"" ) "fixed_width=true;fixed_height=true;" (strcat "width=" (if (not Width) "20" (itoa Width))";" ) (strcat "height=" (if (not Height) "20" (itoa Height))";" ) (if (not DblClck) (strcat "multiple_select=" (if MSelect "true;" "false;") ) "multiple_select=false;" ) "}" (cond ( (zerop Btns) "cancel_button;") ( (= 1 Btns) "ok_only;") (T "ok_cancel;") ) "}" ) (write-line % f) ) (not (close f)) (< 0 (setq dc (load_dialog tmp))) (new_dialog "StdListDialog" dc "" (cond ( *cd-TempDlgPosition* ) ( (quote (-1 -1)) ) ) ) ) ) ) ( T (start_list "list") (mapcar (quote add_list) Data) (end_list) (if (not Pos) (setq Pos 0) (if (> Pos (length Data)) (setq Pos 0)) ) (setq res (set_tile "list" (itoa Pos))) (action_tile "list" (strcat "(setq res $value)(if DblClk (if(or(not MSelect)" "(not (zerop Btns)))" "(if (= $reason 4)(setq " "*cd-TempDlgPosition* (done_dialog 1)))))" ) ) (action_tile "accept" "(setq *cd-TempDlgPosition* (done_dialog 1))") (action_tile "cancel" "(setq res nil) (done_dialog 0)") (setq res (if (= 1 (start_dialog)) (read (strcat "(" res ")")) nil ) ) ) ) (if (< 0 dc) (unload_dialog dc)) (if (setq tmp (findfile tmp)) (vl-File-Delete tmp)) (if (not DPos) (setq *cd-TempDlgPosition* (list -1 -1))) (if res (if (= 1 (length res)) (car res) res)) ) (princ "\n Type NVM to Invoke ") (princ) thanks
  17. leonucadomi

    add new scale to list...

  18. I agree, then there will be another version.: ;; Rectangle on the non-printable "LayDef" layer, LWEIGHT 0.5, color 2 yellow ;; Based on the Lee Mac code 02.10.2025 (defun c:RectLayDef_N ( / cec cel cla ) (setq cec (getvar 'cecolor)) (setvar 'cecolor "2") (setq cel (getvar 'celweight)) (setvar "celweight" 50) (setq cla (getvar 'clayer)) (command "_.-LAYER" "_M" "LayDef" "_C" 2 "LayDef" "_LW" 0.50 "LayDef" "_P" "_N" "LayDef" "") (setvar 'clayer "LayDef") (initcommandversion) (vl-cmdf "_.rectang") (while (= 1 (logand 1 (getvar 'cmdactive))) (vl-cmdf "\\")) (setvar 'cecolor cec) (setvar 'celweight cel) (setvar 'clayer cla) (princ) )
  19. It worked successfully. But I need ctrl + z to get true results. Because it was run automatically this code: "Change ByBlock to ByLayer? [Yes/No] <Yes>:". If you have time, please edit code to fix this. I run on autocad 2021. Thank you
  20. I renamed your thread, please use descriptive titles.
  21. You should avoid using Defpoints layer, Defpoints layer in AutoCAD is automatically created when dimensions are added and is intended to hold definition points for those dimensions. While some users may place objects on this layer to prevent them from printing, it is generally not recommended as it can lead to unexpected issues in the drawing. Create a new no plot layer instead and use that.
  22. For those who don't like clouds Sometimes you need to highlight something and you can forget that the frame needs to be deleted. ;; Rectangle on the Defpoints layer, LWEIGHT 0.5, color 2 yellow ;; Based on the Lee Mac code (defun c:RectLayDefcol2 ( / cec cel cla ) (setq cec (getvar 'cecolor)) (setvar 'cecolor "2") (setq cel (getvar 'celweight)) (setvar "celweight" 50) (setq cla (getvar 'clayer)) (command "_.-LAYER" "_M" "Defpoints" "") (initcommandversion) (vl-cmdf "_.rectang") (while (= 1 (logand 1 (getvar 'cmdactive))) (vl-cmdf "\\")) (setvar 'cecolor cec) (setvar 'celweight cel) (setvar 'clayer cla) (princ) )
  23. It's brilliant! The revcloud is immediately drawn as a cloud! Thanks!
  24. BIGAL

    add new scale to list...

    Another using radio buttons. (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (setq ans (ah:butts but "V" '("Choose a Scale" "1:10" "1:20" "1:50" "1:100" "1:200" "1:250" "1:500" "1:1000"))) ; ans holds the button picked as an integer value or Multi radio buttons.lsp
  25. mhupp

    add new scale to list...

    Shout out to @alanjt for doing the heavy lifting here. This will generate a temp DCL Menu with a list provided and whatever you pick will change the scale accordingly. could be cleaned up a bit with error handling of making sure you selected a viewport or if your in an active viewport pick that one by default. ;;----------------------------------------------------------------------------;; ;; Generates DCL Menu for user to select a veiwport Scale (defun C:VPS () (C:VPSCALE)) (defun C:VPSCALE (/ lst vp) (vl-load-com) (setq Doc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark Doc) (setq lst '("1:1" "1:5" "1:10" "1:15" "1:20" "1:30" "1:40" "1:50" "1:60" "1:70" "1:80" "1:90" "1:100")) ;update list how you see fit (if (setq vp (car (entsel "\nSelect viewport: "))) (progn (setq vp (vlax-ename->vla-object vp)) (setq scl (AT:ListSelect "Set Viewport Scale" "Pick A Scale" 30 60 "False" lst)) (setq X (atoi (substr scl 3))) (vla-put-CustomScale vp (/ 1.0 X)) (vla-Regen Doc acAllViewports) ;might not be needed (princ (strcat "\nViewport scale set to " scl)) ) ) (vla-endundomark Doc) (princ) ) ;;----------------------------------------------------------------------------;; ;; Function to Pick form list ;; Alan J. Thompson, 09.23.08 / 05.17.10 (rewrite) ;; (AT:ListSelect "Title" "Lable" Height Width "true/false multi select" lst) ;; some coding borrowed from http://www.jefferypsanders.com (thanks for the DCL examples) (defun AT:ListSelect (title label height width multi lst / fn fo d f) (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line (strcat "list_select : dialog { label = \"" title "\"; spacer;") fo) (write-line (strcat ": list_box { label = \"" label "\";" "key = \"lst\";") fo) (write-line (strcat "allow_accept = true; height = " (vl-princ-to-string height) ";") fo) (write-line (strcat "width = " (vl-princ-to-string width) ";") fo) (write-line (strcat "multiple_select = " multi "; } spacer; ok_cancel; }") fo) (close fo) (new_dialog "list_select" (setq d (load_dialog fn))) (start_list "lst") (mapcar (function add_list) lst) (end_list) (setq item (set_tile "lst" "0")) (action_tile "lst" "(setq item $value)") (setq f (start_dialog)) (unload_dialog d) (vl-file-delete fn) (if (= f 1) ((lambda (s / i s l) (while (setq i (vl-string-search " " s)) (setq l (cons (nth (atoi (substr s 1 i)) lst) l)) (setq s (substr s (+ 2 i))) ) (reverse (cons (nth (atoi s) lst) l)) ) item ) ) ) -edit Set x as integer with atoi
  26. Last week
  27. hello: I'm trying to make a routine that adds new scale to my viewports I want the routine to only ask me a scale number. example . 20 and it generated the scale 1:20 and so on for others I started with this code but something happens and it doesn't work (defun c:EVP3 (/ ESC ESC2) (setq old_err *error*)(defun *error* ( a / )(princ "") (setq *error* old_err)(princ)) (setvar "cmdecho" 0) (setq ESC (getreal "\nIndica la escala: ")) (setq ESC2 (strcat "1" ":" ESC)) (command "_-SCALELISTEDIT" "A" ESC2 ESC2 "E") (princ) );fin defun enlighten me masters ... please thanks
  28. You can put the prompts in the getpoint. Note the \n this is make a new line on command prompt. (prompt "Specify the first point of the rectangle: ") (setq p1 (getpoint)) (prompt "Specify the opposite point of the rectangle: ") (setq p2 (getcorner p1)) ; *** rlx (setq p1 (getpoint "\nSpecify the first point of the rectangle: ")) (setq p2 (getcorner p1 "\nSpecify the opposite point of the rectangle: ")) ; *** rlx
  29. Just be aware a 3dface is normally 4 points, making a 3dpoly with 3 sides is a different object so import to CIV3D etc may not work without extra steps.
  1. Load more activity
×
×
  • Create New...