Jump to content

Leaderboard

Popular Content

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

  1. 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
  2. Not asked by you but you may want to set GALLERYVIEW to 0. Among others having that on means that the dim styles will be shown as an icon rather than a name, some (many?) find it annoying and half baked.
    1 point
  3. You're welcome @KLipski - I'm glad you were able to resolve the issue in my absence. The sample function I have posted will simply return nil if anything is not as it should be - you may want to have the function write a description to an error log when something isn't right (since you won't be able to observe any error messages at the command-line during the Script operation).
    1 point
  4. 1 point
  5. Generally speaking, you are right. The marketing people have to keep doing things to keep AutoCAD "fresh". You see, until they get everyone on rental, they need NEW customers for cash flow.. The way to get NEW customers is to make sure your product is flashy and 'modern' looking. Regardless if those things are actually productive (or counter-productive, in many cases). Remember, it's the shareholders whom must be satisfied at the end of the day, above everything else. Re: the Ribbon. IMO, yes, it's clunkier in general, but the contextual tabs make up for that, especially with a vertical such as Civil 3D.
    1 point
  6. I don't think @Steve Johnson has done a post specifically for 2019, but this one for 2017 titled [AutoCAD 2017 – Putting things back to “normal”] should cover a lot of the issues you are facing.
    1 point
  7. Perhaps this is what you want? (setq l '("Bridge" "Building" "Canal" "Gas_Pipe" "Railway_Station")) (car (vl-sort l '(lambda (a b) (> (strlen a) (strlen b)))))
    1 point
  8. 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
  9. Eldon, That's one of the great things about AutoCAD, as well as other software. There's always more than one way to accomplish a given task. And I'm always amazed at how other people come up with very ingenious ways of doing things. That's what's great about this Forum.
    1 point
  10. Try this (defun c:shortest ( / *error* ss p_lst min_l s_lst) (defun *error* ( msg ) (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred."))) (princ) );_end_*error*_defun (setq c_doc (vla-get-activedocument (vlax-get-acad-object)) ss (ssget '((0 . "LWPOLYLINE") (70 . 1))) );end_setq (if ss (vlax-for obj (vla-get-activeselectionset c_doc) (setq p_lst (cons (list (vlax-get-property obj 'length) obj) p_lst)) );end_for (alert "Nothing Selected") );end_if (cond (p_lst (setq s_lst (vl-sort p_lst (function (lambda (x y) (< (car x) (car y))))) min_l (caar s_lst) p_lst (vl-remove-if-not (function (lambda (x) (= (car x) min_l))) s_lst) s_lst nil );end_setq (mapcar '(lambda (x) (setq s_lst (cons (cadr x) s_lst))) p_lst) (foreach a s_lst (vla-highlight a :vlax-true)) (alert (strcat "There" (if (> (length p_lst) 1) " are " " is ") (itoa (length p_lst)) (if (> (length p_lst) 1) " entities of length : " " entity of length : ") (rtos min_l 2 3))) ) );end_cond );end_defun min_l - contains the shortest distance s_lst - contains all the vla-objects that have a length of min_l The last two lines (foreach a s_lst (vla-highlight a :vlax-true)) (alert (strcat "There" (if (> (length p_lst) 1) " are " " is ") (itoa (length p_lst)) (if (> (length p_lst) 1) " entities of length : " " entity of length : ") (rtos min_l 2 3))) are only included for demonstration purposes and can be removed I've included a selection process as part of the routine. This will only select closed lwpolylines.
    1 point
  11. Once the string is matched in a list then the length of that string would be the one with the desired length. eg: (if (setq f (member "Railway_Station" '("Bridge" "Building" "Canal" "Gas_Pipe" "Railway_Station"))) (strlen (car f)) )
    1 point
  12. Try (vl-position "Railway_Station" '("Bridge" "Building" "Canal" "Gas_Pipe" "Railway_Station"))
    1 point
  13. You're welcome. You can use member function to find a member from a list and be mindful is that the string would be case sensitive in this case. (member "Railway_Station" '("Bridge" "Building" "Canal" "Gas_Pipe" "Railway_Station"))
    1 point
  14. As such, it would likely be cleaner to perform the block insertion as part of the function, e.g.: (defun inserttitleblock ( dwg csv / att lst ) (if (and (setq dwg (findfile dwg)) (setq csv (findfile csv)) (setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cadr x))) (LM:readcsv csv))) (setq scl (cdr (assoc (strcase (vl-filename-base (getvar 'dwgname))) lst))) ) (progn (setq att (getvar 'attreq)) (setvar 'attreq 0) (vl-cmdf "_.-insert" dwg "_S" scl "_R" "0" "_non" "0,0,0") (setvar 'attreq att) ) ) ) You may then call the above with the block filepath & CSV filepath: (inserttitleblock "C:/Project/TitleBlock.dwg" "C:/YourCSVFile.csv")
    1 point
  15. No worries, I thought you just wanted the max number of the second list and not the primary one. (apply 'max (mapcar 'strlen '("Bridge" "Building" "Canal" "Gas_Pipe" "Railway_Station")))
    1 point
  16. 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
  17. Create plane ► select Z axis ► select YZ plane input angle.
    1 point
×
×
  • Create New...