Results 1 to 8 of 8

Thread: Lips routine for special Array

Hybrid View

  1. #1
    Member
    Join Date
    2011-09
    Posts
    5

    Default Lips routine for special Array

    Hy,

    Can anyone help me with an lisp for inserting block link in the picture attached?
    Now i use an lisp called DivideMeasurePlus.lsp for each side to determinate the insertion points. But i need something more rapid. Only to insert the block name, number of rows , number of columns, max dist. of row and max distance of column.
    Attached Images Attached Images

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    6,836

    Default Re: Lips routine for special Array

    What steps do you take now to calculate that information? Write those steps out and we can help you convert them to code.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Member
    Join Date
    2011-09
    Posts
    5

    Default Re: Lips routine for special Array

    1: I draw the red line for the 2 wall
    2 I use div+ commeand cu devide like in the drawing attached with the line parrameter.
    3 At the intersection of the magenta lines i paste the block.


    If i have a room with lets say 1 colomn and 2 rows of lights is very simpla i only use the div+ command and it put the block instead of line i used before.
    Attached Images Attached Images

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    6,836

    Default Re: Lips routine for special Array

    I've never heard or seen the div+ command.

    BTW, are you looking for someone to put all of the pieces together to make a complete routine? Or do you want to learn how to do something of this nature?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Member
    Join Date
    2011-09
    Posts
    5

    Default Re: Lips routine for special Array

    I'm looking for someone that already did this routine or can create it.
    I attached the div+ that i use maybe that help.
    Attached Files Attached Files

  6. #6
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,211

    Default Re: Lips routine for special Array

    Quote Originally Posted by ionutste898627 View Post
    Hy,

    Can anyone help me with an lisp for inserting block link in the picture attached?
    Now i use an lisp called DivideMeasurePlus.lsp for each side to determinate the insertion points. But i need something more rapid. Only to insert the block name, number of rows , number of columns, max dist. of row and max distance of column.
    Here is one I posted few years ago
    See if this helps
    (Change block name within the code):
    Code:
    (defun C:ELEC (/  *error* bk bname dx dy leg m n osm p1 p2 p3 p4 pmin pn px py req wid)
    (defun *error* (msg)
      (cond
        (or
         (not msg)
         (member msg
          (list "console break"
         "Function cancelled"
         "quit / exit abort"))
         )
        )
     (if msg (princ (strcat "\nError: " msg))
       )
    (command "_ucs" "_p")
    (setvar 'cmdecho 1)
    (setvar 'attdia 1)
    (setvar 'qaflags 0)
    (if req (setvar 'attreq req))
    (if osm (setvar 'osmode osm))
      (command "_undo" "_end")
      (princ)
      )
     
      (defun 3dPoint->2dPoint (3dpt)
      (list (float (car 3dpt)) (float (cadr 3dpt)))
    );end of 3dPoint->2dPoint
     
    (command "_undo" "_begin")
    (setq bname "blk");<-- change block name here
    (if (not (tblsearch "block" bname))
      (progn
        (alert (strcat "Block"  "\"" bname "\"" " does not exist.\nProgram exiting..."))
        (exit)(princ))
      )
    (setvar 'cmdecho 0)
    (command "_ucs" "_w")
    (setq osm  (getvar 'osmode))
    (setq req (getvar 'attreq))
    (setq p1 (getpoint "\nFirst corner: "))
    (setq p3 (getcorner p1 "\nOpposite corner: "))
    (setq p1  (3dPoint->2dPoint p1)
          p3  (3dPoint->2dPoint p3)
          p2  (list (car p3) (cadr p1))
          p4  (list (car p1) (cadr p3))
          leg (distance p1 p2)
          wid (distance p1 p4)
          )
      (command "_zoom" p1 p3)
    (setq m (getint "\n Number of rows: " )
          n (getint "\n Number of columns: " )
          dx (/ leg n 2. )
          dy dx
          leg (- leg (* dx 2.))
          wid (- wid (* dy 2.))
          )
    (setq px (apply 'min (mapcar 'car (list p1 p2 p3 p4)))
          py(apply 'min (mapcar 'cadr (list p1 p2 p3 p4)))
          pn (list px py)
          pmin (car (vl-remove-if-not
        (function (lambda(a)
             (and (equal (car a)(car pn)0.001)
           (equal (cadr a)(cadr pn)0.001)))
           )  (list p1 p2 p3 p4))
      )
          px (+ px dx)
          py (+ py dy)
          )
     (setq pmin (list px py))
    (setvar 'attdia 0)
    (setvar 'attreq 0)
    (setvar 'osmode 0)
    (setvar 'qaflags 1)
    (command "-insert" "blk" (trans pmin 1 0) "1.0"  "0.0");<-- change block name here
    (setvar 'qaflags 0)
    (setq bk (entlast))
      (terpri)
      (setq rows (itoa m)
     cols (itoa n))
    (vl-cmdf "-array" bk "" "_R" m n (/ wid (1- m)) (/ leg (1- n)) )
    (command "_ucs" "_P")
    (*error* nil)
    (princ)
    )
    (prompt "\n   ---   Start command with \"ELEC\" or \"elec\"  ---") 
    (prin1) 
    (or (vl-load-com) 
    (princ) 
        )
    ~'J'~
    "The whole problem with the world is that fools and fanatics are always
    so certain of themselves, and wiser people so full of doubts."
    Bertrand Russell

  7. #7
    Member
    Join Date
    2011-09
    Posts
    5

    Default Re: Lips routine for special Array

    Thank you FIXO i succed to modify the source you send me and this is what i wanted:

    Code:
    (defun C:FLUOET (/  *error* bk bname dx dy leg m n osm p1 p2 p3 p4 pmin pn px py req wid)
    (defun *error* (msg)
      (cond
        (or
         (not msg)
         (member msg
          (list "console break"
         "Function cancelled"
         "quit / exit abort"))
         )
        )
     (if msg (princ (strcat "\nError: " msg))
       )
    (command "_ucs" "_p")
    (setvar 'cmdecho 1)
    (setvar 'attdia 1)
    ;(setvar 'qaflags 0)
    (if req (setvar 'attreq req))
    (if osm (setvar 'osmode osm))
      (command "_undo" "_end")
      (princ)
      )
     
      (defun 3dPoint->2dPoint (3dpt)
      (list (float (car 3dpt)) (float (cadr 3dpt)))
    );end of 3dPoint->2dPoint
     
    (command "_undo" "_begin")
    (setq bname "fluo_et");<-- change block name here
    (if (not (tblsearch "block" bname))
      (progn
        (alert (strcat "Block"  "\"" bname "\"" " does not exist.\nProgram exiting..."))
        (exit)(princ))
      )
    (setvar 'cmdecho 0)
    (command "_ucs" "_w")
    (setq osm  (getvar 'osmode))
    (setq req (getvar 'attreq))
    (setq p1 (getpoint "\nFirst corner: "))
    (setq p3 (getcorner p1 "\nOpposite corner: "))
    (setq p1  (3dPoint->2dPoint p1)
          p3  (3dPoint->2dPoint p3)
          p2  (list (car p3) (cadr p1))
          p4  (list (car p1) (cadr p3))
          leg (distance p1 p2)
          wid (distance p1 p4)
          )
     ; (command "_zoom" p1 p3)
    
      (princ (* leg wid))   ;ionut - afiseaza aria camerei
    (setq m (getint "\n Number of rows: " )
          n (getint "\n Number of columns: " )
          dx (/ leg n 2. ) ;determina prima jumatate
          dy (/ wid m 2. )
          leg (- leg (* dx 2.)) ;determina distanta dintre randuri/coloare(fara prima jumatate de segement)
          wid (- wid (* dy 2.))
          )
    (setq px (apply 'min (mapcar 'car (list p1 p2 p3 p4)))
          py(apply 'min (mapcar 'cadr (list p1 p2 p3 p4)))
          pn (list px py)
          pmin (car (vl-remove-if-not
        (function (lambda(a)
             (and (equal (car a)(car pn)0.001)
           (equal (cadr a)(cadr pn)0.001)))
           )  (list p1 p2 p3 p4))
      )
          px (+ px dx)
          py (+ py dy)
          )
     (setq pmin (list px py))
    (setvar 'attdia 0)
    (setvar 'attreq 0)
    (setvar 'osmode 0)
    (setvar 'qaflags 1)
    (command "-insert" "fluo_et" (trans pmin 1 0) "1.0"  "0.0");<-- change block name here
    (setvar 'qaflags 0)
    (setq bk (entlast))
      (terpri)
      (setq rows (itoa m)
     cols (itoa n))
    (vl-cmdf "-array" bk "" "_R" m n (if 
    					(= 0 (1- m)) 
    							(/ leg (1- n)) 
    									(/ wid (1- m))) 
    				(if 
    					(= 0 (1- n)) 
    							"1" 
    								(/ leg (1- n))) ) ; (/ wid (1- m)) (/ leg (1- n)) )
    (command "_ucs" "_P")
    (command "-osnap" "End,Mid,Cen,Int,Ins,Perp") ;- readuce la starea initiala osnap
    (*error* nil)
    (princ)
    )
    (prompt "\n   ---   Start command with \"FLUOET\" or \"FLUOET\"  ---") 
    (prin1) 
    (or (vl-load-com) 
    (princ) 
        )

  8. #8
    Member
    Join Date
    2011-09
    Posts
    5

    Smile Re: Lips routine for special Array

    Thank you, it was closed, i modified a little for what i need
    But it still has a littl error if in need only 1 row and more colomns or 1 colmon and more rows it insert only one block:

    (defun C:ELEC (/ *error* bk bname dx dy leg m n osm p1 p2 p3 p4 pmin pn px py req wid)
    (defun *error* (msg)
    (cond
    (or
    (not msg)
    (member msg
    (list "console break"
    "Function cancelled"
    "quit / exit abort"))
    )
    )
    (if msg (princ (strcat "\nError: " msg))
    )
    (command "_ucs" "_p")
    (setvar 'cmdecho 1)
    (setvar 'attdia 1)
    (setvar 'qaflags 0)
    (if req (setvar 'attreq req))
    (if osm (setvar 'osmode osm))
    (command "_undo" "_end")
    (princ)
    )

    (defun 3dPoint->2dPoint (3dpt)
    (list (float (car 3dpt)) (float (cadr 3dpt)))
    );end of 3dPoint->2dPoint

    (command "_undo" "_begin")
    (setq bname "fluo_et");<-- change block name here
    (if (not (tblsearch "block" bname))
    (progn
    (alert (strcat "Block" "\"" bname "\"" " does not exist.\nProgram exiting..."))
    (exit)(princ))
    )
    (setvar 'cmdecho 0)
    (command "_ucs" "_w")
    (setq osm (getvar 'osmode))
    (setq req (getvar 'attreq))
    (setq p1 (getpoint "\nFirst corner: "))
    (setq p3 (getcorner p1 "\nOpposite corner: "))
    (setq p1 (3dPoint->2dPoint p1)
    p3 (3dPoint->2dPoint p3)
    p2 (list (car p3) (cadr p1))
    p4 (list (car p1) (cadr p3))
    leg (distance p1 p2)
    wid (distance p1 p4)
    )
    (command "_zoom" p1 p3)
    (setq m (getint "\m Number of rows: " )
    n (getint "\n Number of columns: " )
    dx (/ leg n 2. )
    dy (/ wid m 2. )
    leg (- leg (* dx 2.))
    wid (- wid (* dy 2.))
    )
    (setq px (apply 'min (mapcar 'car (list p1 p2 p3 p4)))
    py(apply 'min (mapcar 'cadr (list p1 p2 p3 p4)))
    pn (list px py)
    pmin (car (vl-remove-if-not
    (function (lambda(a)
    (and (equal (car a)(car pn)0.001)
    (equal (cadr a)(cadr pn)0.001)))
    ) (list p1 p2 p3 p4))
    )
    px (+ px dx)
    py (+ py dy)
    )
    (setq pmin (list px py))
    (setvar 'attdia 0)
    (setvar 'attreq 0)
    (setvar 'osmode 0)
    (setvar 'qaflags 1)
    (command "-insert" "fluo_et" (trans pmin 1 0) "1.0" "0.0");<-- change block name here
    (setvar 'qaflags 0)
    (setq bk (entlast))
    (terpri)
    (setq rows (itoa m)
    cols (itoa n))
    (vl-cmdf "-array" bk "" "_R" m n (/ wid (1- m)) (/ leg (1- n)) )
    (command "_ucs" "_P")
    (*error* nil)
    (princ)
    )
    (prompt "\n --- Start command with \"ELEC\" or \"elec\" ---")
    (prin1)
    (or (vl-load-com)
    (princ)
    )

Similar Threads

  1. Special Layer Freeze LISP Routine
    By dbanker in forum AutoLISP
    Replies: 7
    Last Post: 2008-04-14, 07:29 AM
  2. Window with Array of Mullions but Array Group Doesn't like Constrants!
    By billyn in forum Revit Architecture - Families
    Replies: 4
    Last Post: 2007-07-18, 02:03 PM
  3. Array an Object, then Array all those Objects another way
    By Coolmo in forum Dynamic Blocks - Technical
    Replies: 9
    Last Post: 2007-04-19, 03:51 AM
  4. Parametric Drawer Front with array (problems controling array)
    By robert.manna in forum Revit Architecture - Families
    Replies: 4
    Last Post: 2007-04-04, 05:17 AM

Posting Permissions

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