+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Full Member
    Using
    AutoCAD 2007
    Join Date
    Mar 2005
    Location
    Sao Paulo - SP - Brazil
    Posts
    64

    Default COUNTING? GROUPING?

    Registered forum members do not see this ad.

    Hello!

    First of all, imagine this building, which has some big "panels" (concrete panels) all over it:



    Now, imagine that, all those "big concrete panels" have some "small panels" (something made with rock, for eg.), like this now:



    Ok.
    As you can see, there are several sizes of "small rock panels", which could be grouped by the "big ones", like this (I´m gonna call the BG=big ones, and SM=small ones):

    GROUP BG1:
    - SM1 / SM1
    (Like it repeated 2 times)
    - SM2
    - SM3


    GROUP BG2:
    - SM1
    (yeah, again, for example!)
    - SM5
    - SM6
    - SM7


    ETC, ...

    You see, even though the big ones sometimes have some similar small ones, they´re still grouped separately. That means, the big ones could be the "group name", and the "small ones" would be the objects inside these groups.


    This lisp would have to "compare" both size and "grouping", so it could name corretly, and also tell me that I have 2 BG1, 10 BG2, etc...


    Maybe this lisp would create separate blocks for each group in a folder.
    Each SM would be a block and the BG groups would be blocks too, with blocks "inside".

    After all that I would use "Attribute Extractor" to count all of them.

    All I would have to do is to draw the polylines, for the BG and SM, and the lisp would compare, name, group, make blocks, etc... All alone.

    Is it... too complicated?
    Tiring is trying to explain the obvious for those who are devoted to distortions of the concepts

  2. #2
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Hi,
    I thought you need to do something like this
    (just an idea only):
    I created a couple of blocks with following names:
    "12.5x18.5" "18.5x18.5" "38.5x18.5" "38.5x38.5" "52.0x38.5" "73.0x38.5" etc. etc.
    All the block you can to store into one library block file.
    All the blocks with insertion point in the lower left corner,
    with one invisible constant attribute:
    tag - "SIZE"
    prompt - "Tile size"
    value - "(38.5x18.5)", etc - (or length multiple by width)
    Panel size:
    length - 120.
    width - 90.

    Code:
    ;get tile length by block name
    (defun get_length (block_name)
      (atof
        (substr block_name 1 (vl-string-search "x" block_name))
      )
    )
    
    ;get tile width by block name  
    (defun get_width (block_name)
      (atof
        (substr block_name (+ (vl-string-search "x" block_name) 2))
      )
    )
    
    ;get all the tiles
    (defun get-tiles-by-first (len	       wid	   lower_gap
    			   upper_gap   gap_between left_gap
    			   right_gap   tile_len	   tile_wid)
    
        ;| * : go through tiles in counterclockwise direction : |;
        (list
        ;| #1 : lower left tile : |;
        (cons tile_len tile_wid)
        ;| #2 : lower right tile : |;
        (cons (- len (+ left_gap tile_len gap_between right_gap))
    	  tile_wid
        )
        ;| #3 : upper right tile : |;
        (cons (- len (+ left_gap tile_len gap_between right_gap))
    	  (- wid (+ lower_gap gap_between upper_gap tile_wid))
        )
        ;| #4 : upper leftt tile : |;
        (cons tile_len
    	  (- wid (+ lower_gap gap_between upper_gap tile_wid))
        )
      )
    )
    
      ;get all the blocks
      (defun get-block-names (block_name   len	  wid
    			lower_gap    upper_gap	  gap_between
    			left_gap     right_gap
    		       )
      (setq	tile_len (get_length block_name)
    	tile_wid (get_width block_name)
      )
      (setq	tiles_data
    	 (get-tiles-by-first
    	   len		wid	     lower_gap	  upper_gap
    	   gap_between	left_gap     right_gap	  tile_len
    	   tile_wid
    	  )
      )
      (mapcar (function
    	    (lambda (x)
    	      (strcat (rtos (car x) 2 1) "x" (rtos (cdr x) 2 1))
    	    )
    	  )
    	  tiles_data
      )
    )
    
    ;;;TesT : 
    (setq block_names
           (get-block-names
    	 &#40;strcat &#40;getstring "\nEnter first tile length with decimal delimiter <like 73.0> \n"&#41;
    		 "x"
    		 &#40;getstring "\nEnter a tile width with decimal delimiter <like 38.5>\n"&#41;&#41;
    	 120. ;panel length
    	 90. ;panel width
    	 3.125 ;upper gap
    	 5.875 ;lower gap
    	 4. ;gap between
    	 2. ;left gap
    	 2. ;right gap
    	 &#41;
    &#41;
    ~'J'~

  3. #3
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Going further...

    Code:
    ; to insert block from block library file
    &#40;defun dwg-insert &#40;dwg_name	block_name   ins_point	  x_scale
    		   y_scale	rot_angle    /		  lib_file
    		  &#41;
      &#40;if &#40;not &#40;tblsearch "BLOCK" block_name&#41;&#41;
        &#40;progn
          &#40;setvar "cmdecho" 0&#41;
          &#40;setq lib_file &#40;findfile dwg_name&#41;&#41;
          &#40;if &#40;not lib_file&#41;
    	&#40;progn
    	  &#40;alert "Library is not found"&#41;
    	  &#40;exit&#41;
    	  &#40;princ&#41;
    	&#41;
    	&#40;progn
    	  &#40;command "-insert" lib_file&#41;
    	  &#40;command nil&#41;
    	&#41;
          &#41;
        &#41;
      &#41;
      &#40;if &#40;tblsearch "BLOCK" block_name&#41;
        &#40;progn
          &#40;command "-insert"   block_name  "_X"	   x_scale
    	       "_Y"	   y_scale     "_R"	   rot_angle
    	       ins_point
    	      &#41;
          &#40;command "purge" "_B" "*" "_N"&#41;
        &#41;
      &#41;
      &#40;setvar "cmdecho" 1&#41;
      &#40;princ&#41;
    &#41;
    ; Test &#58;
    &#40;defun C&#58;test1
           &#40;/ block_name dwg_name ins_point rot_angle x_scale y_scale&#41;
      &#40;setq	dwg_name   "C&#58;/MyLisp/tornillo-com.dwg"
    	block_name "ALLEM-cc-03-08"
    	ins_point  &#40;getpoint "\nPick ins point >>>\n"&#41;
    	x_scale	   1.
    	y_scale	   1.
    	rot_angle  0.
      &#41;
      &#40;dwg-insert
        dwg_name block_name	ins_point x_scale y_scale rot_angle&#41;
      &#40;princ&#41;
    &#41;
    ;CaLL &#58; &#40;C&#58;test1&#41;
    Then you can to count all the blocks
    and write data in to any file i.e. txt-file:

    Code:
    &#40;defun sub-total &#40;lst elem / count&#41;
      &#40;setq count 0&#41;
      &#40;while &#40;member elem lst&#41;
        &#40;setq count &#40;1+ count&#41;&#41;
        &#40;setq lst &#40;cdr &#40;member elem lst&#41;&#41;&#41;
      &#41;
      count
    &#41;
    ;CaLL &#58; &#40;setq sub-count &#40;sub-total count_list bname&#41;&#41;
    &#40;defun get-total &#40;source_list match_list / data_list&#41;
      &#40;foreach i match_list
        &#40;setq tmp	    &#40;cons i &#40;sub-total source_list i&#41;&#41;
    	  data_list &#40;cons tmp data_list&#41;
        &#41;
      &#41;
      data_list
    &#41;
    ;CaLL &#58; &#40;setq data_list &#40;get-total count_list bname_list&#41;&#41;
    &#40;defun get-count &#40;/ bname bname_list count_list elist en i ssb&#41;
      &#40;setvar "cmdecho" 0&#41;
      &#40;command "zoom" "e"&#41;
      &#40;setvar "cmdecho" 1&#41;
      &#40;if &#40;setq ssb &#40;ssget "_X" &#40;list &#40;cons 0 "INSERT"&#41; &#40;cons 2 "*#x#*"&#41;&#41;&#41;&#41;
        &#40;progn
          &#40;setq i -1&#41;
          &#40;repeat &#40;sslength ssb&#41;
    	&#40;setq en    &#40;ssname ssb &#40;setq i &#40;1+ i&#41;&#41;&#41;
    	      elist &#40;entget en&#41;
    	      bname &#40;cdr &#40;assoc 2 elist&#41;&#41;
    	&#41;
    	&#40;if &#40;not &#40;member bname bname_list&#41;&#41;
    	  &#40;setq bname_list &#40;cons bname bname_list&#41;&#41;
    	&#41;
    	&#40;setq count_list &#40;cons bname count_list&#41;&#41;
          &#41;
        &#41;
        &#40;alert "No blocks found here"&#41;
      &#41;
      &#40;get-total count_list bname_list&#41;
    &#41;
    ;CaLL &#58; &#40;setq data &#40;get-count&#41;&#41;
    &#40;defun write-data &#40;data / fname&#41;
      &#40;setq
        fname &#40;getstring
    	    "\nEnter file name to write data in without extension &#58;"
    	  &#41;
      &#41;
      &#40;setq fname &#40;open &#40;strcat &#40;getvar "dwgprefix"&#41; fname "." "txt"&#41; "w"&#41;&#41;
      &#40;foreach i data
        &#40;prin1 i fname&#41;
      &#41;
      &#40;close fname&#41;
      &#40;princ&#41;
    &#41;
    						  ;CaLL &#58;&#40;write-data data&#41;
    &#40;defun read-data &#40;/ data_list fname rline&#41;
      &#40;setq	fname &#40;getstring
    		"\nEnter file name to read data without extension &#58;"
    	      &#41;
      &#41;
      &#40;setq fname &#40;open &#40;strcat &#40;getvar "dwgprefix"&#41; fname "." "txt"&#41; "r"&#41;&#41;
      &#40;setq rline &#40;read-line fname&#41;&#41;
      &#40;setq data_list &#40;read &#40;strcat "&#40;" rline "&#41;"&#41;&#41;&#41;
      &#40;close fname&#41;
      &#40;reverse data_list&#41;
    &#41;
    ;CaLL &#58;&#40;setq ret_data &#40;read-data&#41;&#41;
    
    ;;TesT &#58; 
    &#40;defun C&#58;test2 &#40;/ data&#41;
      &#40;setq data &#40;get-count&#41;&#41;
      &#40;write-data data&#41;
      &#40;princ&#41;
    &#41;
    ;CaLL &#58; &#40;C&#58;test2&#41;
    ~'J'~

  4. #4
    Full Member
    Using
    AutoCAD 2007
    Join Date
    Mar 2005
    Location
    Sao Paulo - SP - Brazil
    Posts
    64

    Default

    Hi Fatty,

    First I´d like to thank you to put so much of your time in it.

    This lisp is not doing "exactly" what I was thinking about.
    Maybe I´m missing something. Let´s see:

    - I create the polyline
    - I create the attribute
    - I create the block

    After all that I write TEST2, then the text file is created.

    I put all the three parts of the code together. Was I supposed to do that?

    Well, if I did everything correct, I´d have to do almost everything on my own. Imagine a whole building, with hundreds of big panels, which of them with different small panels. Let´s say this building have 200 big panels. And each big panels has 4 small panels.

    It would give me like 800 small panels.

    Maybe my problem here is the english.... sorry!


    All I want to do BEFORE the lisp getting in is:

    - draw big rectangles (the yellow ones, in my first post)
    - draw small rectangles inside the big ones (the grey ones now)

    All polylines...
    The "blocking" would be the "lisp´s job".

    I don´t think I know all the words to make my self clearer...
    And I don´t even know if it´s possible to do what I want...

    Any ideas?

    THank you very much!
    Tiring is trying to explain the obvious for those who are devoted to distortions of the concepts

  5. #5
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Quote Originally Posted by fade2blackened
    Hi Fatty,

    First I´d like to thank you to put so much of your time in it.

    This lisp is not doing "exactly" what I was thinking about.
    Hi,

    Sorry now is too late for me, see you tomorrow
    I will try to do what you asked me, but don't sure if this will be

    ~'J'~

  6. #6
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Sorry, buddy, I couldn't understand exactly what you need
    because of my poor english level
    I have stopped my weak attempts to help you ...

    Here is an example how to fill panel with blocks, change all
    by your needs:

    Code:
    &#40;vl-load-com&#41;
    ;get all the tiles
    &#40;defun get-tiles-by-first &#40;len	       wid	   lower_gap
    			   upper_gap   gap_between left_gap
    			   right_gap   tile_len	   tile_wid&#41;
    
        ;| * &#58; go through tiles in counterclockwise direction &#58; |;
        &#40;list
        ;| #1 &#58; lower left tile &#58; |;
        &#40;cons tile_len tile_wid&#41;
        ;| #2 &#58; lower right tile &#58; |;
        &#40;cons &#40;- len &#40;+ left_gap tile_len gap_between right_gap&#41;&#41;
    	  tile_wid
        &#41;
        ;| #3 &#58; upper right tile &#58; |;
        &#40;cons &#40;- len &#40;+ left_gap tile_len gap_between right_gap&#41;&#41;
    	  &#40;- wid &#40;+ lower_gap gap_between upper_gap tile_wid&#41;&#41;
        &#41;
        ;| #4 &#58; upper leftt tile &#58; |;
        &#40;cons tile_len
    	  &#40;- wid &#40;+ lower_gap gap_between upper_gap tile_wid&#41;&#41;
        &#41;
      &#41;
    &#41;
    ;;get all the origins
    &#40;defun get-origos &#40;en lower_gap gap_between 
    		   left_gap tile_len tile_wid /
    		   ll obj orig1 orig2 orig3 orig4 up_point ur&#41;
      
          &#40;setq obj &#40;vlax-ename->vla-object en&#41;&#41;
          &#40;vla-getboundingbox obj 'll 'ur&#41;
          &#40;setq orig1 &#40;vlax-safearray->list ll&#41;
    	    up_point &#40;vlax-safearray->list ur&#41;
    	    orig1 &#40;list &#40;+ &#40;car orig1&#41; left_gap&#41;&#40;+ &#40;cadr orig1&#41;lower_gap&#41;&#40;caddr orig1&#41;&#41;
    	    orig2 &#40;list &#40;+ &#40;car orig1&#41; tile_len gap_between&#41;&#40;cadr orig1&#41;&#40;caddr orig1&#41;&#41;
    	    orig3 &#40;list &#40;car orig2&#41;&#40;+ &#40;cadr orig2&#41; tile_wid gap_between&#41; &#40;caddr orig1&#41;&#41;
    	    orig4 &#40;list &#40;car orig1&#41;&#40;cadr orig3&#41;&#40;caddr orig1&#41;&#41;&#41;
          &#40;list orig1 orig2 orig3 orig4&#41;&#41;
    
    &#40;defun C&#58;test4&#40;/ amod bname ccol clyr dim_list en gap_between
    	       ins_pt left_gap len lower_gap orig_list pmt_str
    	       right_gap dim_list ss size_list tag_str upper_gap wid&#41;
      
      &#40;setvar "cmdecho" 0&#41;
      &#40;setvar "osmode" 0&#41;
      &#40;setq ccol &#40;getvar "cecolor"&#41;&#41;
      &#40;setq clyr &#40;getvar "clayer"&#41;&#41;
      &#40;setq amod &#40;getvar "aflags"&#41;&#41;
      &#40;setvar "cecolor" "253"&#41;
      &#40;setvar "clayer" "0"&#41;
      &#40;setvar "aflags" 1&#41;; invisible attribute mode
      
      ;; here is dimension list for all the first &#40;lower left&#41; tiles
      ;; for all the big panels &#40;or you can draw these panels, and
      ;; get their coordinates and dimensions&#41;
      
      &#40;setq size_list '&#40;&#40;18.0 . 18.0&#41;
    		    &#40;38.0 . 18.0&#41;
    		    &#40;52.5 . 18.0&#41;
    		    &#40;52.5 . 38.0&#41;
    		    &#40;72.5 . 38.0&#41;
    		    &#40;72.5 . 52.5&#41;&#41;
    	len 120.;panel length
    	wid 90. ;panel width
    	lower_gap 6.
    	upper_gap 3.125
    	gap_between 4.
    	left_gap 2.
    	right_gap 2.&#41;;_ setq
      
      &#40;repeat &#40;length size_list&#41;
        &#40;setq indx &#40;car size_list&#41;&#41;
        &#40;setq ss &#40;ssget "_&#58;S" &#40;list &#40;cons 0 "*POLYLINE"&#41;&#41;&#41;
    	  en &#40;ssname ss 0&#41;&#41;
        &#40;redraw en 3&#41;
    	 &#40;setq dim_list &#40;get-tiles-by-first len	 wid lower_gap
    			   upper_gap   gap_between left_gap
    			   right_gap   &#40;car indx&#41; &#40;cdr indx&#41;&#41;
    	       orig_list &#40;get-origos en lower_gap gap_between 
    		   left_gap &#40;car indx&#41;&#40;cdr indx&#41;&#41;
    	       &#41;
    	   &#40;repeat 4
    	      &#40;setq bname   &#40;strcat &#40;rtos &#40;caar dim_list&#41; 2 1&#41; "x" &#40;rtos &#40;cdar dim_list&#41; 2 1&#41;&#41;
    	      ins_pt  &#40;car orig_list&#41;
    	      tag_str "TILE"
    	      pmt_str tag_str
    	&#41;
    	&#40;if &#40;not &#40;tblsearch "block" bname&#41;&#41;    
    	&#40;make-tile-block
    	  bname
    	  ins_pt
    	  tag_str
    	  pmt_str
    	  &#40;caar dim_list&#41;
    	  &#40;cdar dim_list&#41;
    	&#41;
    	  &#41;
    	     &#40;command "-insert" bname ins_pt 1 1 0&#41;
    	     &#40;setq dim_list &#40;cdr dim_list&#41;
    		   orig_list &#40;cdr orig_list&#41;&#41;
          &#41;
        &#40;redraw en 4&#41;
    &#40;setq size_list &#40;cdr size_list&#41;&#41;	     
    &#41;	   
    
      &#40;command "regenall"&#41;
      &#40;setvar "cecolor" ccol&#41;
      &#40;setvar "clayer" clyr&#41;
      &#40;setvar "aflags" amod&#41;
        &#40;setvar "osmode" 703&#41;
      &#40;setvar "cmdecho" 1&#41;
      &#40;princ&#41;
    &#41;
    ~'J'~

  7. #7
    Full Member
    Using
    AutoCAD 2007
    Join Date
    Mar 2005
    Location
    Sao Paulo - SP - Brazil
    Posts
    64

    Default

    Dude, I can´t understand how it works...
    Could you give me an example?

    Thank very much!
    Tiring is trying to explain the obvious for those who are devoted to distortions of the concepts

  8. #8
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by fade2blackened
    Dude, I can´t understand how it works...
    Could you give me an example?

    Thank very much!
    Hi again
    There is no need an example
    Simply draw a few yellow rectangles with
    dimensions: Length = 120, Width = 90. and then
    select these one by another
    This routine will fill these panels with blocks

    ~'J'~

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts