Recent Posts

Pages: [1] 2 3 ... 10
1
Seem to remember open a pdf direct just like this (startapp "notepad" "D:\\acadtemp\\test.lsp")

Something a simple as (command "_start" "D:\\acadtemp\\newblock-02.pdf") Worked in my Bricscad.
2
XDRX-API / [XDrX-Function(42)] string sort
« Last post by xdcad on May 10, 2024, 09:39:23 PM »
xdrx-string-logical<

Used to compare two strings in logical order. This function is typically used to sort a list of files to ensure that the files are arranged in a logical order that humans understand, rather than a simple dictionary order.

example:

Command: (acad_strlsort (list "file200.txt" "file100.txt" "file10.txt" "file5.txt"))
("file10.txt" "file100.txt" "file200.txt" "file5.txt")


Command: (vl-sort (list "file200.txt" "file100.txt" "file10.txt" "file5.txt") '(lambda(x y)(xdrx-string-logical< x y)))
("file5.txt" "file10.txt" "file100.txt" "file200.txt")

Code - Auto/Visual Lisp: [Select]
  1. (defun xd::string:sortlist (strl)
  2.   (vl-sort strl '(lambda (x y) (xdrx_string_logical< x y)))
  3. )
  4.  
  5. ;assoc string list sort
  6.  
  7. (defun xd::string:assocsortlist (strl)
  8.   (vl-sort strl '(lambda (x y) (xdrx_string_logical< (car x)(car y))))
  9. )


xd::string:assocsortlist
_$

(("file100.txt" (1 2 3)) ("file0.txt" (1 2 3)) ("file20.txt" (1 2 3)) ("file300.txt" (1 2 3)))
(("file0.txt" (1 2 3)) ("file20.txt" (1 2 3)) ("file100.txt" (1 2 3)) ("file300.txt" (1 2 3)))
_$
3
I have lsip that opens Microsoft Edge and then launches my default PDF reader using a function called. Here's the code
(If someone knows who should get credit for this I am more than willing to remark it
Code: [Select]
(defun launchpdf (pdfname / shell)
  (vl-load-com)
  (setq pdfname (vl-string-translate "|" "\\" pdfname))
  (setq shell
        (vla-getinterfaceobject
          (vlax-get-acad-object)
          "Shell.Application"
        )
  )
  (vlax-invoke-method shell 'Open pdfname)
  (vlax-release-object shell)
  (princ)
)

(defun c:cheats ()
  (launchpdf "https://teams.company/revit//revitblog/PublishingImages/New%20user%20Packet/cheatsheet.pdf")
)


However, I'm encountering an issue with hosting a PDF cheatsheet on our company server. Currently, I'm only able to access it via an HTTPS link. Is there a workaround to enable me to keep the cheatsheet on our company server? If I launch the pdf off my computer it works the way I want.

Code: [Select]
(defun c:cheats ()
  (launchpdf "\\\\dt-lshaw2\\dcapps\\help.pdf")
)

Unfortunately, IT has been unable to provide a non-HTTPS link. Any suggestions on how to resolve this would be appreciated."
4
CAD General / Re: Batch Find & Replace Text AutoCAD 2023
« Last post by Lee Mac on May 10, 2024, 12:46:23 PM »
Try setting LISPSYS to 0.
5
AutoLISP (Vanilla / Visual) / Re: 3d polyline splitting
« Last post by ribarm on May 10, 2024, 10:52:29 AM »
@mariolino0099
I've fixed (while) endless loop, but it doesn't follow exact math because segments lengths are less than 0.7 units, so if I divide it with 0.7 and (fix) that number I get 0 - which gives another error - divide by zero... So, I had to include one (if) statement that will ensure that your first *.DWG is processed correctly with verices numbers like you presented on right side 3d polyline, and your second *.DWG is processed with that second - else (if) statement (setq n (fix (1+ (/ dd d)))) ... That 1+ is to ensure that divide by zero doesn't occur...
So, test my codes now, as I think that better than this is not neccessary...
7
.NET / Re: Using the Generic KeyValuePair<>
« Last post by retsameht on May 10, 2024, 05:38:04 AM »
Just a heads up: Don't use the code in this file until I fix it:

https://github.com/ActivistInvestor/AcMgdUtility/blob/main/DocumentCollectionExtensions.cs

UPDATE 5/10/24: Bugs fixed (WaitForIdle(), and WaitUntil() were hanging AutoCAD :oops:).

WaitForIdle() is a solution to a problem that has irked me for a long time (handling the next Application.Idle event). I had previously dealt with it using a class that wraps the handler for the event, but that still required the code to be run in the Idle event handler to be passed in a delegate.

WaitForIdle() is a far-simpler and better solution that requires nothing but an awaited method call, followed by the code that should run after the Idle event is raised.

Code - C#: [Select]
  1. /// WaitForIdle():
  2.  
  3. public static async void MyMethod()
  4. {
  5.    var DocMgr = Application.DocumentManager;
  6.    
  7.    // wait for an Idle event to be raised:
  8.    
  9.    await DocMgr.WaitForIdle();
  10.    
  11.    // Code appearing here will not run until
  12.    // the next Idle event is raised and there
  13.    // is an active document.
  14.    
  15.    var doc = DocMgr.MdiActiveDocument;      
  16.    doc.Editor.WriteMessage("An Idle event was raised.");
  17. }
  18.  
  19.  
  20. /// WaitUntil():
  21.  
  22. public static async void MyMethod()
  23. {
  24.    var DocMgr = Application.DocumentManager;
  25.    
  26.    // Waits until there is an active document
  27.    // that is in a quiescent state:
  28.    
  29.    await DocMgr.WaitUntil(doc => doc.Editor.IsQuiescent);
  30.    
  31.    // Code appearing here will not run until
  32.    // the next Idle event is raised; there is
  33.    // an active document; and that document
  34.    // is in a quiescent state.
  35.    
  36.    var doc = DocMgr.MdiActiveDocument;      
  37.    doc.Editor.WriteMessage("The Drawing Editor is quiescent");
  38. }
  39.  
  40.  
8
AutoLISP (Vanilla / Visual) / Re: 3d polyline splitting
« Last post by mariolino0099 on May 10, 2024, 02:37:53 AM »
hello ribarm
thanks for the help, i edited the line first
  (if (setq s (ssget "_.+:E:S" (list (cons 0 "POLYLINE") (cons -4 "<or") (cons 70 8) (cons 70 9) (cons -4 "or>"))))
because it was going to error.
For the four-vertex 3dpoly works, in the more complicated case (example_1.dwg) it seems to going inside a infinite loop...
Am I doing something wrong ?
Is possible to select multiple 3dpoly ?

Thnaks



Code: [Select]
    (defun c:split3dpolysegs ( / *error* getvertices unit d cmd uf s plx pl vl a b dd n sd nvl k )
     
      (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com))
     
      (defun *error* ( m )
        (if uf
          (if command-s
            (command-s "_.UCS" "_P")
            (vl-cmdf "_.UCS" "_P")
          )
        )
        (if cmd
          (setvar (quote cmdecho) cmd)
        )
        (if m
          (prompt m)
        )
        (princ)
      )
     
      (defun getvertices ( c / i p plst )
        (setq i -1)
        (while (<= (setq i (1+ i)) (vlax-curve-getendparam c))
          (setq p (vlax-curve-getpointatparam c i))
          (setq plst (cons p plst))
        )
        (reverse plst)
      )
     
      (defun unit ( v / d )
        (if (not (equal (setq d (distance (list 0.0 0.0 0.0) v)) 0.0 1e-6))
          (mapcar (function (lambda ( x ) (/ x d))) v)
        )
      )
     
;      (setq d 1) ;;; initial setting - change to suit your needs ;;;
     
      (setq cmd (getvar (quote cmdecho)))
      (setvar (quote cmdecho) 0)
      (if (= 0 (getvar (quote worlducs)))
        (progn
          (if command-s
            (command-s "_.UCS" "_W")
            (vl-cmdf "_.UCS" "_W")
          )
          (setq uf t)
        )
      )
 
  (initget 7)
  (setq
d (getreal "\nEnter Max Distance between Polyline Vertices : "
)
  )
 
 
      (prompt "\nPick reference 3D polyline...")
      (if (setq s (ssget "_+.:E:S" (list (cons 0 "POLYLINE") (cons -4 "<or") (cons 70 8) (cons 70 9) (cons -4 "or>"))))
        (progn
          (setq plx (entget (setq pl (ssname s 0))))
          (setq vl (getvertices pl))
          (while (setq b (cadr vl))
            (if (< d (setq dd (distance (setq a (car vl)) b)))
              (progn
                (setq n (fix (/ dd d)))
                (setq sd (/ dd n))
                (setq nvl (cons a nvl))
                (setq k 0)
                (repeat n
                  (setq nvl (cons (mapcar (function +) a (mapcar (function *) (unit (mapcar (function -) b a)) (list (* (setq k (1+ k)) sd) (* k sd) (* k sd)))) nvl))
                )
                (setq vl (cdr vl))
              )
            )
          )
          (setq a (car nvl))
          (setq nvl (cdr nvl))
          (if (not (vlax-curve-isclosed pl))
            (setq nvl (cons a nvl))
          )
          (setq nvl (reverse nvl))
          (vl-cmdf "_.3DPOLY")
          (foreach v nvl
            (vl-cmdf "_non" v)
          )
          (if (vlax-curve-isclosed pl)
            (while (< 0 (getvar (quote cmdactive)))
              (vl-cmdf "_C")
            )
            (while (< 0 (getvar (quote cmdactive)))
              (vl-cmdf "")
            )
          )
        )
      )
      (*error* nil)
    )
     
9
.NET / Re: PropertySetDefinition with a List data type
« Last post by Hanauer on May 09, 2024, 04:37:17 PM »
I have been using DataGridViewComboBoxColumn and getting satisfactory results.
If you could post part of the code of the final solution you arrived at, I would be grateful.
10
.NET / Re: PropertySetDefinition with a List data type
« Last post by Jeff_M on May 09, 2024, 03:59:18 PM »
A bit of headway made ... I changed the DataTable column to be a typeof Dictionary<string, List<string>> so I can put the current value as the Key and the List as the value to be used in the DataGrid. However, when the DataGrid columns are auto-generated, the column with the Dictionary is created as a DataGridTextColumn. I think that what I am after is to have that column be a DataGridComboBoxColumn set with the cell set to the value and the selected item set the Key of the dictionary.

I believe I'm on the right track here, just really struggling on how to accomplish it. WPF, MVVM, c#  :uglystupid2:
Pages: [1] 2 3 ... 10