Jump to content

Leaderboard

Popular Content

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

  1. You can use my Read CSV function for this task - here is a quick example: (defun c:test ( / csv lst scl ) (cond ( (not (setq csv (getfiled "Select CSV File" "" "csv" 16))) (princ "\n*Cancel*") ) ( (not (setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cadr x))) (LM:readcsv csv)))) (princ "\nUnable to read CSV file or CSV file is empty.") ) ( (not (setq scl (cdr (assoc (strcase (vl-filename-base (getvar 'dwgname))) lst)))) (princ (strcat "\n" (vl-filename-base (getvar 'dwgname)) " not found in 1st column of " (vl-filename-base csv) ".csv.")) ) ( (princ (strcat "\nFound scale: " scl))) ) (princ) )
    1 point
  2. If you were going to the trouble of implementing an trial license, you would of course compile the entire application to a separate-namespace vlx, meaning that the definition of the LM:InternetTime function could not be modified (or, rather, any definition would not affect the definition within the vlx namespace) as it resides outside of the document namespace.
    1 point
  3. The easiest way is to use the contiguous Julian date system, e.g.: ( (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.") ) ( (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 ) Here, the Express Tools' dtoj function is only used to make it easier to specify the expiration date in the code - you can easily remove this reliance by specifying the expiration date as a Julian date directly in the code. Note that this approach is still susceptible to the user changing the system clock - hence the suggestion to use my Internet Time function above.
    1 point
  4. @DavidGraham - does this help any? (Click on VPORT in left frame)
    1 point
  5. If you use layouts each dwg would be at real scale as the layout view would be scaled, the title block being in the layout is at 1:1 scale, so no factor required.
    1 point
  6. There is no way of specifying a random selection, since items are stored sequentially in the drawing database. You either need to selected multiple entities, generate a random integer and then access that item in the selection set or you become the random select mode using "ssget" in single select mode. If the latter and assuming you are talking about LWPolylines, try the following lisp (defun c:testzw ( / ss ll ur) ;define local variables (setq ss (ssget "_+.:E:S:L" '((0 . "LWPOLYLINE") (70 . 1) (60 . 0)))) (vla-getboundingbox (vlax-ename->vla-object (ssname ss 0)) 'll 'ur) (vla-zoomwindow (vlax-get-acad-object) ll ur) );end_defun Explanation of above code. If using the above the (60 . 0) isn't really useful as you can't select an invisible object, but it is useful when using ssget with "_X" since this gets all objects in the database ; This selects all closed (70 . 1) visible (60 . 0) LWPolylines in the drawing. The filter is a quoted list of dxf dotted pairs (setq ss (ssget "_X" '((0 . "LWPOLYLINE") (70 . 1) (60 . 0)))) ; This is single entity selection mode (simulates entsel) excluding objects on locked layers (:L) Filter as above (setq ss (ssget "_+.:E:S:L" '((0 . "LWPOLYLINE") (70 . 1) (60 . 0)))) ; Should you want to include a layer to further filter the list (setq ss (ssget "_+.:E:S:L" '((0 . "LWPOLYLINE") (8 . "LAYERNAME") (70 . 1) (60 . 0)))) ; In single selection mode this will get the single entity in the selection set (ssname ss 0) and converts it to a vla-object ; and then get the extents (boundingbox) of the object, returning the two points as variants into the specified ; variables (ll and ur). Note that the variable names are quoted, and should be defined in any lisp as unquoted ; local variable so they can be converted or used later (vla-getboundingbox (vlax-ename->vla-object (ssname ss 0)) 'll 'ur) ; This uses the variables from above (without extracting the values) and plugs them straight into the visual lisp ; zoomwindow method, since this requires two points as variants. It is therefore uneconomical to convert them to coord list and back again (vla-ZoomWindow (vlax-get-acad-object) ll ur)
    1 point
  7. You're most welcome @amir0914 - You may find my Dump Object utility useful in this regard - it's a simple program and merely a wrapper for the vlax-dump-object function to allow you to select a primary or nested object.
    1 point
  8. The following program will allow you to specify either a block name, attribute tag, or attribute value (or all three), and will return a selection of all blocks matching the given criteria, residing in the current layout: ;; Block Selection - Lee Mac ;; Selects all blocks in the current layout with a given block name or which contain a specified attribute tag and/or value. (defun c:bsel ( / att atx blk cnt ent enx flg idx sel str tag ) (setq blk (strcase (getstring t "\nSpecify block name <any>: ")) tag (strcase (getstring "\nSpecify attribute tag <any>: ")) str (strcase (getstring t (strcat "\nSpecify attribute value" (if (= "" tag blk) ": " " <any>: ")))) ) (if (not (= "" str tag blk)) (if (and (setq sel (ssget "_X" (append '((000 . "INSERT")) (if (not (= "" tag str)) '((066 . 1))) (if (/= "" blk) (list (cons 2 (strcat "`*U*," blk)))) (if (= 1 (getvar 'cvport)) (list (cons 410 (getvar 'ctab))) '((410 . "Model")) ) ) ) ) (progn (repeat (setq idx (sslength sel)) (setq ent (ssname sel (setq idx (1- idx))) enx (entget ent) ) (cond ( (not (or (= "" blk) (wcmatch (strcase (LM:name->effectivename (cdr (assoc 2 enx)))) blk))) (ssdel ent sel) ) ( (member (cdr (assoc 66 enx)) '(nil 0))) ( (progn (setq att (entnext ent) atx (entget att) flg nil ) (while (and (= "ATTRIB" (cdr (assoc 0 atx))) (not (and (or (= "" str) (wcmatch (strcase (cdr (assoc 1 atx))) str)) (or (= "" tag) (wcmatch (strcase (cdr (assoc 2 atx))) tag)) ) ) ) (setq att (entnext att) atx (entget att) ) ) (= "SEQEND" (cdr (assoc 0 atx))) ) (ssdel ent sel) ) ) ) (< 0 (setq cnt (sslength sel))) ) ) (progn (princ (strcat "\n" (itoa cnt) " block" (if (= 1 cnt) "" "s") " found.")) (sssetfirst nil sel) ) (princ "\nNo blocks found.") ) ) (princ) ) ;; Block Name -> Effective Block Name - Lee Mac ;; blk - [str] Block name (defun LM:name->effectivename ( blk / rep ) (if (and (wcmatch blk "`**") (setq rep (cdadr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" blk)))) '("acdbblockrepbtag") ) ) ) ) (setq rep (handent (cdr (assoc 1005 rep)))) ) (cdr (assoc 2 (entget rep))) blk ) ) (princ)
    1 point
  9. Hi there. I think David is still active, hoping he wont mind. Here'S what you need. Using the implied "_I" filter instead of "x". (good example of wanting to highlight a selection set too...) (defun c:randset (/ ss sl i en el ep pct qty rs) ;;;SMadsen Random Number (defun randnum (/ modulus multiplier increment random) (if (not seed) (setq seed (getvar "DATE"))) (setq modulus 65536 multiplier 25173 increment 13849 seed (rem (+ (* multiplier seed) increment) modulus) random (/ seed modulus))) (cond ((setq ss (ssget "i")) (sssetfirst nil nil) (setq sl (sslength ss) i -1) (while (setq en (ssname ss (setq i (1+ i)))) (setq el (cons en el)))) (T (alert "\nNo Entities Found") (exit))) (initget 7) (setq pct (getreal "\nPercentage To Randomly Choose: ")) (setq qty (fix (* sl pct 0.01))) (setq rs (ssadd)) (while (> qty (sslength rs)) (setq ep (fix (* sl (randnum))) en (nth ep el)) (if (not (ssmemb en rs)) (ssadd en rs))) (sssetfirst nil rs) (princ) ) That will form the selection you need. Cheers
    1 point
×
×
  • Create New...