Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/06/2020 in all areas

  1. Try this rework. Tested on your provided drawing. (defun c:hat (/ ss cnt obj ar tot) (setq tot 0 ss (ssget '((0 . "HATCH")))) (cond (ss (repeat (setq cnt (sslength ss)) (setq obj (vlax-ename->vla-object (setq ent (ssname ss (setq cnt (1- cnt)))))) (if (vl-catch-all-error-p (setq ar (vl-catch-all-apply 'vlax-get (list obj 'area)))) (progn (vl-cmdf "hatchgenerateboundary" ent "") (setq ar (getpropertyvalue (entlast) "area"))(entdel (entlast))) ) (setq tot (+ tot ar)) ) (alert (strcat "Total Area : "(rtos tot 2 3))) ) ) (princ) ) The hatch in question had three duplicate points at the start of the reinstated boundary polyline.
    1 point
  2. @Lee Mac Thanks for your help AGAIN! You the man! You the man! @dlanorh sorry to hear about your situation - I wish you all the best and I wish her some comfort at the time she needs it the most. Thank you guys for replying to my half-but requests on this forum.
    1 point
  3. The obvious answer given the existing code provided by the OP would be to simply iterate over the list of files returned by the vl-directory-files function using a foreach loop, and evaluate the read_only user-defined function for every file within the loop, e.g.: (setq dir "C:\\TX Cad Config\\Block\\") (foreach dwg (vl-directory-files dir "*.dwg" 1) (read_only (strcat dir dwg)) ) However, this approach is highly inefficient, as the code is instantiating the File System Object (FSO) and then testing the existence of every file processed, when only one instance of the FSO is required, and the files are already known to exist given that they are being returned by the vl-directory-files function. With this in mind, a slightly more efficient approach might be: (defun c:test ( / dir fob fso lst ) (if (and (setq dir "C:\\TX Cad Config\\Block\\" lst (vl-directory-files dir "*.dwg" 1) ) (setq fso (vlax-create-object "scripting.filesystemobject")) ) (progn (foreach dwg lst (setq fob (vlax-invoke fso 'getfile (strcat dir dwg))) (vlax-put-property fob 'attributes (logior 1 (vlax-get fob 'attributes))) (vlax-release-object fob) ) (vlax-release-object fso) ) ) (princ) ) You could alternatively use the FSO for all of the file manipulation, including obtaining the set of files within the given folder, e.g.: (defun c:test ( / dir flc fld fso ) (if (setq dir "C:\\TX Cad Config\\Block" fso (vlax-create-object "scripting.filesystemobject") ) (progn (vl-catch-all-apply '(lambda ( ) (setq fld (vlax-invoke fso 'getfolder dir) flc (vlax-get fld 'files) ) (vlax-for fob flc (if (wcmatch (strcase (vlax-get fob 'name) t) "*.dwg") (vlax-put-property fob 'attributes (logior 1 (vlax-get fob 'attributes))) ) ) ) ) (if flc (vlax-release-object flc)) (if fld (vlax-release-object fld)) (vlax-release-object fso) ) ) (princ) ) However, the following simple solution is likely to be far more efficient, especially for large folders of files: (defun c:test ( ) (command "_.shell" "attrib +r \"C:\\TX Cad Config\\Block\\*.dwg\"") (princ) ) Aside - I can't understand why you replied knowing that the advice offered was inaccurate?
    1 point
×
×
  • Create New...