Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/09/2019 in all areas

  1. *Must have done something wrong before, but when tested your code bombs on '(vlax-vla-object->ename r)'
    1 point
  2. lido If you need good protection, you need to use a ready-made solution. Write a request to this company: http://www.star-force.com/ They make protection on programs, and they make protection on Lisp. All your protection requirements they can do is not a problem. I have been using this protection for a long time.
    1 point
  3. Here you go. Tested on 1000 polylines. FOO2 is a quick mod of my vl-sort ( brought to light a while back by Michael Puckett @ TheSwamp ) (defun foo2 (s / _a a l) (defun _a (e) (vlax-curve-getdistatparam e (vlax-curve-getendparam e))) (cond ((setq l (cdar (vl-sort (mapcar '(lambda (x) (cons (_a x) x)) (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))) '(lambda (r j) (< (car r) (car j))) ) ) ) (sssetfirst nil (ssadd l)) ) ) (princ) )
    1 point
  4. No, as the function retrieves the UTC time from the NIST time server (http://time.nist.gov).
    1 point
  5. You need to start with the basics then use simple command method as a start. Keep using polar to work out new points and drawing objects like a circle then trim to clean up. look up the help for explanation of the commands below. There is some missing distances in the sketch you will have to make some choices. Getpoint Getreal or Getdist Polar to work out new points (setq pt1 (getpoint "Pick lower left point")) (setq a (getreal "Enter length A")) (setq b (/ a 0.6)) (setq h (getreal "Enter offset H")) (setq h1 (- (/ b 3.0) 5.0)) (setq pt2 (polar pt1 0.0 b)) (setq pt3 (polar pt2 (/ pi 2.0) a)) (setq pt4 (polar pt3 pi b)) (command "line" pt1 pt2 pt3 pt4 pt1 "")
    1 point
  6. Mac address PC Date Internet date Hard disk ID Regapp entry Autocad serial number Ping a web server Lots of methods available Oh yeah the phone call "the software is not working how do I fix ?" bottom line the end user tried to install on another computer without paying.
    1 point
  7. Sorry. Try this. (defun c:lighmpoly (/ lEnt lVal) (if (setq sSet (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1)))) (setq sSet (car (sssetfirst nil (ssadd (nth (vl-position (apply ;; (function max) ;;longest (function min) (mapcar (function (lambda (x / y) (setq y (vla-get-length (vlax-ename->vla-object x)) lVal (cons y lVal) ) y ) ) (setq lEnt (vl-remove-if (function listp) (mapcar (function cadr) (ssnamex sSet) ) ) ) ) ) lVal ) (reverse lEnt) ) ) ) ) ) ) ;; (if lVal (/ (apply (function +) lVal) (length lVal))) ;;average (princ) )
    1 point
  8. For a shortest pline, it would be interesting to know which is the fastest solution. Bench them all if you have a little time. (defun c:minlpoly (/ lSet) (if (setq lSet (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1)))) (apply (function min) (mapcar (function (lambda (x)(vla-get-length (vlax-ename->vla-object x))) ) (vl-remove-if (function listp) (mapcar (function cadr) (ssnamex lSet) ) ) ) ) ) )
    1 point
  9. OP cross posted .. has many options to choose from.
    1 point
  10. Here's another method: (defun c:shortestpoly ( / a d e i l s ) (if (setq s (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1)))) (progn (setq e (ssname s 0) l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) i 0 ) (while (setq i (1+ i) a (ssname s i)) (if (< (setq d (vlax-curve-getdistatparam a (vlax-curve-getendparam a))) l) (setq l d e a) ) ) (sssetfirst nil (ssadd e)) ) ) (princ) ) This will offer efficiency gains for large sets since the selection is only iterated once (therefore fewer comparisons & length calculations than a sort operation), without the need for conversion to a list (which can be slow when ssnamex is used, since this returns more information than is required). Nothing against Ron's code
    1 point
  11. FWIW, for longer list lengths, you'll want to consider using a function such as this to determine the extrema for a given function applied over a list, since this will involve far fewer comparisons than a sort operation. For your example, this would be: _$ (setq l '("Bridge" "Building" "Canal" "Gas_Pipe" "Railway_Station")) ("Bridge" "Building" "Canal" "Gas_Pipe" "Railway_Station") _$ (extremum '(lambda ( a b ) (> (strlen a) (strlen b))) l) "Railway_Station"
    1 point
  12. Try something like this: (defun c:foo (/ _a a l s) ;; RJP » 2019-01-08 ;; Returns shortest closed polyline (defun _a (e) (vlax-curve-getdistatparam e (vlax-curve-getendparam e))) (cond ((setq s (ssget '((0 . "lwpolyline") (-4 . "&=") (70 . 1)))) (setq l (vl-sort (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) '(lambda (r j) (< (_a r) (_a j))) ) ) (sssetfirst nil (ssadd (car l))) ) ) (princ) )
    1 point
  13. >> Can this be modified to ask for number of objects to be selected, instead of percentage? Instead of this: (setq pct (getreal "\nPercentage To Randomly Choose: ")) (setq qty (fix (* sl pct 0.01))) do this: (setq qty (geting "\nNumber of items to be selected: "))
    1 point
  14. Indeed you can - consider a function such as the following: ;; MAC Addresses - Lee Mac ;; Returns a list of MAC Addresses for all installed network adaptors (defun LM:macaddresses ( / err qry srv wmi ) (if (setq wmi (vlax-create-object "wbemscripting.swbemlocator")) (progn (setq err (vl-catch-all-apply (function (lambda ( / rtn ) (setq srv (vlax-invoke wmi 'connectserver) qry (vlax-invoke srv 'execquery "select macaddress from win32_networkadapter where macaddress is not null") ) (vlax-for itm qry (setq rtn (cons (vlax-get itm 'macaddress) rtn))) ) ) ) ) (foreach obj (list qry srv wmi) (if (= 'vla-object (type obj)) (vlax-release-object obj) ) ) (if (vl-catch-all-error-p err) (prompt (vl-catch-all-error-message err)) err ) ) ) )
    1 point
  15. Wow nice one, Lee! Well I could also violate a bit Autodesk's terms of use, by appending the dtoj function definition into the expiration date wrapper. Ofcourse this doesn't sound like the right thing to do, but on the other hand the algorithm could be replicated (if its not already somewhere on the internet) and overall doesn't do any harm. I remember we were doing such clock-adjusting back in the 90's in order to run some expired programs I find your LM:InternetTime great, but theres one thing to keep in mind, since when defined the subfunction remains "public" - It must be defined while running the expiration wrapper...else one could simple redefine your sub in order to bypass the checks like so: (defun LM:InternetTime ( format ) "01.01.99" ; "MO.DD.YY" ) Assuming the "bad" guy nailed the date format. Thats why I try to keep some stuff localised/private within a scope. Thanks Lee!
    1 point
  16. Can I add a MacAddress? ( (lambda ( date expdate / dif ) (if (cond ( (not (or dtoj (and (load "julian.lsp" nil) dtoj)))) ( (<= (setq dif (- (fix (dtoj expdate)) date)) 0) (alert "Program has expired.") ) ( (not get_macaddress) (princ "\nFunction get_macaddress is not loaded.") ) ( (not (eq MyMacAddress (get_macaddress))) (princ "\nYou have no permission to run this routine.") ) ( (progn (alert (strcat "Program will expire in " (itoa dif) " day" (if (= 1 dif) "." "s."))) t)) ) (progn (defun c:test ( ) (alert "Hello World!") (princ) ) ) ) ) (fix (getvar 'date)) 20190131 )
    1 point
  17. Internet Time Thanks for the recommendation @BIGAL
    1 point
×
×
  • Create New...