Recent Posts

Pages: 1 ... 8 9 [10]
91
AutoLISP (Vanilla / Visual) / Re: Searching for nested BLOCKs ( Recursive )
« Last post by Grrr1337 on January 12, 2017, 02:47:55 pm »
My attempt:

Code - Auto/Visual Lisp: [Select]
  1. (defun NestedBlock ( blk / Lst )
  2.    (cond
  3.      ((and (eq "AcDbBlockReference" (vla-get-ObjectName o)) (not (member (vla-get-EffectiveName o) Lst)))
  4.        (setq Lst (cons (vla-get-EffectiveName o) Lst))
  5.        (NestedBlock o)
  6.      )
  7.    ); cond
  8.  ); vlax-for
  9.  (cons (vla-get-EffectiveName blk) (reverse Lst))
  10. ); defun NestedBlock

Code - Auto/Visual Lisp: [Select]
  1. (defun C:test ( / blk )
  2.  (if
  3.    (and
  4.      (setq blk (car (entsel "\nPick a block: ")))
  5.      (= "INSERT" (cdr (assoc 0 (entget blk))))
  6.    )
  7.    (alert (vl-princ-to-string (NestedBlock (vlax-ename->vla-object blk))))
  8.  )
  9.  (princ)
  10. ); defun test

Result is like:
Code - Auto/Visual Lisp: [Select]
  1. ("MyMainBlock" "MyFirstBlock" "MySecondBlock" "MyThirdBlock")

I was thinking about this before and thought that it would be cool if the return list is nested, representing the nested levels inside the block, like the above should be:
Code - Auto/Visual Lisp: [Select]
  1. ("MyMainBlock" ("MyFirstBlock" ("MySecondBlock" ("MyThirdBlock"))))
92
AutoLISP (Vanilla / Visual) / Re: Searching for nested BLOCKs ( Recursive )
« Last post by Lee Mac on January 12, 2017, 02:24:28 pm »
Quickly written - not sure if this will be any quicker to run:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:nestblk ( / b i l s )
  2.    (if (setq s (ssget '((0 . "INSERT"))))
  3.        (repeat (setq i (sslength s))
  4.            (setq b (cdr (assoc 2 (entget (ssname s (setq i (1- i)))))))
  5.            (or (member b l)
  6.                (foreach n (nested b)
  7.                    (or (member n l) (setq l (cons n l)))
  8.                )
  9.            )
  10.        )
  11.    )
  12.    (setq nested:cache nil)
  13.    (print l) (princ)
  14. )
  15. (defun nested ( b / e l n x )
  16.    (cond
  17.        (   (assoc b nested:cache))
  18.        (   (setq e (tblobjname "block" b))
  19.            (while (setq e (entnext e))
  20.                (if (= "INSERT" (cdr (assoc 0 (setq x (entget e)))))
  21.                    (foreach n (cons (setq n (cdr (assoc 2 x))) (nested n))
  22.                        (or (member n l) (setq l (cons n l)))
  23.                    )
  24.                )
  25.            )
  26.            (car (setq nested:cache (cons (cons b l) nested:cache)))
  27.        )
  28.    )
  29. )
93
AutoLISP (Vanilla / Visual) / Searching for nested BLOCKs ( Recursive )
« Last post by David Bethel on January 12, 2017, 01:56:04 pm »

I'm trying to compile a list of BLOCKs names ( selected and nested in the selection set )

I'm no expert on recursive functions, but this looks like the only way.

My kludge so far :

  • No dynamics blocks
  • Just a single name ( no counting req'd )
  • Just simple model space

Code - Auto/Visual Lisp: [Select]
  1. ;;RECURSIVE SEARCH
  2. (defun nw_nestb (b / nt ne nd nb)
  3.  (setq nt (tblsearch "BLOCK" b)
  4.        ne (cdr (assoc -2 nt)))
  5.  (while ne
  6.    (setq nd (entget ne))
  7.    (and (= "INSERT" (cdr (assoc 0 nd)))
  8.         (setq nb (cdr (assoc 2 nd)))
  9.         (not (member nb bl))
  10.         (setq bl (cons nb bl))
  11.         (nw_nestb nb))
  12.     (setq ne (entnext ne))    )
  13.  (length bl))
  14.  
  15.  
  16. ;;;MAIN PROGRAM
  17. (defun c:nestblk (/ ss i en ed bn) ; bl
  18.  (setq bl nil)
  19.  (while (not ss)
  20.         (princ "\nSelect Blocks To Search...")
  21.         (setq ss (ssget '((0 . "INSERT")))))
  22.  (setq i 0)
  23.  (while (setq en (ssname ss i))
  24.         (setq ed (entget en)
  25.               bn (cdr (assoc 2 ed)))
  26.         (and (not (member bn bl))
  27.              (setq bl (cons bn bl))
  28.              (nw_nestb bn))
  29.         (setq i (1+ i)))
  30.  
  31.  (setq bl (acad_strlsort bl))
  32.  
  33.  (prin1 bl))

It is slow as molasses and ugly as sin.


Any suggestions ?  TIA  -David
94
CAD General / Re: Vector Geometry Problem, Reverse Curves with Tangents
« Last post by Lee Mac on January 12, 2017, 01:48:50 pm »
I'm sure there is an easier way, but the following demonstrates one possible construction:



Snapping could have been made easier, but I didn't want to change the zoom in order to keep everything in frame.
95
Revit / Re: Viewing revit models
« Last post by rvhwlc on January 12, 2017, 01:03:46 pm »
revit is free 30 days then goes into viewer mode... cannot save or print or export so it becomes a viewer..
96
Revit / Re: Viewing revit models
« Last post by John Kaul (Se7en) on January 12, 2017, 12:22:45 pm »
Note: A full version of Naisworks will allow you to create a project file and will read a "Navisworks" view in your model to populate the project. A free version of Navisworks (called: Freedom), you have to export a DWF for the mgrs to view (adopting the problems in workflow you are asking about).
97
AutoLISP (Vanilla / Visual) / Re: Minimum rectangle
« Last post by ribarm on January 12, 2017, 12:10:20 pm »
I've changed my previous post... Had some lacks and further more, if MIRROR is allowed then results can be even better... Check here attached LISP with attached DWG... Area of rectangle should be ab 400 DWG units... If used without MIRROR it gives back with previously posted code ab 408 units...

HTH., M.R.
98
AutoLISP (Vanilla / Visual) / Change Layer Properties By Object Selection
« Last post by Dave M on January 12, 2017, 11:51:14 am »
I have a routine (not written by me) that will allow one to change a layer's properties by selecting an object on the layer you want to change the properties of.  It will even work if the layer is nested in an xref or block.  It does not work in 2016, and it is protected so I can't modify it myself. 


Does anyone know of a similar routine that would work in 2016?


Thanks!
99
Revit / Re: Viewing revit models
« Last post by alterego on January 12, 2017, 11:23:34 am »
Thank you for your reply Jeff

That sounds a bit more promising...  A follow up question regarding this method is how would you stop other users accidentally saving a model (for example to a newer version?)

On a fast paced job I think it might be difficult for the modellers to keep writing navis files for the in-house senior engineers to keep checking... or is there a better workflow?
100
AutoLISP (Vanilla / Visual) / Re: Find geographic location of user using IP address
« Last post by VovKa on January 12, 2017, 11:07:53 am »
API to return an XML with location information?

https://www.theswamp.org/index.php?topic=33065.0

will return you current location
Code: [Select]
(vk_ReadXML "http://freegeoip.net/xml/")
you may also specify specific IP
Code: [Select]
(vk_ReadXML "http://freegeoip.net/xml/8.8.8.8")
Pages: 1 ... 8 9 [10]