Results 1 to 9 of 9

Thread: Repeated Block Insertion

  1. #1
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Repeated Block Insertion

    I am trying to have the user enter a number of filter rows and the filter frame size then depending on the entry have it insert blocks into the drawings according to the amoutn of filter rows. 10 filter rows = 10 blocks. The thing is that every other block is rotated at 60 degrees. I just can not figure out how to have the correct number of blocks show up in the drawing. Currently working correctly are 2, 3, and 4 filter rows so you can use them to see what i am trying to do. The 2" Angled Filter block has to be placed in a support directory search path.

    Code:
    (defun C:AngFilter ()
      (setq angf (getreal "Enter Number of Filter Rows: "));; getting number of filter rows
      (setq angftype (getreal "Enter Filter Frame Size (2\"or4\"): "));;getting filter frame size
      (setq angfpnt (getpoint "Select Filter placement"));;Select where you want the filter 
        (setq angfpnt1 (list (-(car angfpnt)1.1065)(-(cadr angfpnt)1.8913)));; setting insertion point of filter rotated at 60 degrees
      (if (and(= angftype 2)(= angf 2))
        (progn
      (command "insert" "2in. Angled Filter" angfpnt1 """""-60");; Inserting filters
       (command "insert" "2in. Angled Filter" angfpnt """""");; Inserting filters
        )
        (progn
      (command "insert" "2in. Angled Filter" angfpnt1 """""-60");; Inserting filters
       (command "insert" "2in. Angled Filter" angfpnt """""");; Inserting filters
      (ang)
        )
        
      )
     )
    ;;;;;Setting up Insertion point for filter block
    (defun ang ()
      (while (and(= angftype 2)(> angf 2))
        (setq angfpnt (list (car angfpnt)(-(cadr angfpnt)27.5136)))setting insertion point for the while function
        (command "insert" "2in. Angled Filter" angfpnt """""");; Inserting filter
        (setq angf (- angf 2)) setting count
       
      )
      (setq angf (+ angf 2))
      (if(and(= angftype 2)(> angf 3))
      (ang1))
    )
    ;;;Setting up insertion point for Rotated filter 
    (defun ang1 ()
        (while (and(= angftype 2)(> angf 3))
          (progn
        (setq angfpnt1 (list (car angfpnt1)(-(cadr angfpnt1)27.5136)))
        (command "insert" "2in. Angled Filter" angfpnt1 """""-60")
        (setq angf (- angf 1))
          )
        )
      
    )
    Note: I don't like the way i have written this program it looks choppy and messy to me so feel free to rewrite or reorganize it they way you feel best. ALL help is appreciated.
    Attached Files Attached Files
    Last edited by Lions60; 2007-01-03 at 05:46 PM.

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,105
    Login to Give a bone
    0

    Default Re: Repeated Block Insertion

    In the future, I would recommend you either comment your code for easier reading for others or use descriptive variable and function names. You use ang for the beginning of most of your variable and function names. I usually associate the ang prefix to a variable involving an angle.

    I'm still looking into your code at the moment and post back in a bit.
    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
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Repeated Block Insertion

    I added commenting to the program to explain it to the best of my ability. I use the "ang" at the beginning of my variables because these are angled filters that are being inserted. So angftype = Angled Filter Type, angfpnt = Angled Filter Point. So on and so forth.

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,105
    Login to Give a bone
    0

    Default Re: Repeated Block Insertion

    Try this.

    Code:
    (defun C:AngFilter ()
      (setq angf (getreal "Enter Number of Filter Rows: "))
      ;; getting number of filter rows
      (setq angftype (getreal "Enter Filter Frame Size (2\"or4\"): "))
      ;;getting filter frame size
      (setq angfpnt (getpoint "Select Filter placement"))
      ;;Select where you want the filter
      (setq angfpnt1 (list (- (car angfpnt) 1.1065) (- (cadr angfpnt) 1.8913))
      )
      ;; setting insertion point of filter rotated at 60 degrees
      (if (= angftype 2) ;; 2" Frame Size
        (progn
          (setq BlockName "2in. Angled Filter")
          (setq BlockRotation -60.0) ;; Set Predefined Angle
          (setq BlockRotate BlockRotation)
          (repeat (fix angf) ;; Repeat number of Rows 
    	(setq BlockRotate (* -1.0 (+ (abs BlockRotation) BlockRotate))) ;;Rotate Block formula
    	(if (minusp BlockRotate) ;; Check for Negative Rotation Angle
    	  (setq	InsertPoint angfpnt1
    		;; Set Insertion Point
    		angfpnt1 (list (- (car angfpnt) 1.1065)
    			       (- (cadr angfpnt) 1.8913)
    			 )
    		;; setting insertion point of filter rotated at 60 degrees
    	  )
    	  (setq	InsertPoint angfpnt
    		;; Set Insertion Point
    		angfpnt (list (car angfpnt) (- (cadr angfpnt) 27.5136))
    		;;setting insertion point for the while function
    	  )
    	)
    	(command "insert" BlockName InsertPoint "" "" BlockRotate)
    	;; Inserting filters
          )
        )
        (progn
          ;; Replace this portion for coding of the 4" Angled Filter
          (t)
        )
      )
    )
    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
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Repeated Block Insertion

    Works like a dream and looks better too. Thanks very much.

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,105
    Login to Give a bone
    0

    Default Re: Repeated Block Insertion

    Quote Originally Posted by Lions60
    Works like a dream and looks better too. Thanks very much.
    You will need to add your code for the 4" Angled Filter. I have set a Place Holder for it.
    Code:
        (progn
          ;; Replace this portion for coding of the 4" Angled Filter
          (t)
        )
    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

  7. #7
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Repeated Block Insertion

    Yea is saw that and have added that code. I am wondering one thing though. What do the functions minusp and abs do. This is the first time i have ever seen those functions. I guess you learn something new everyday.

  8. #8
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,105
    Login to Give a bone
    0

    Default Re: Repeated Block Insertion

    The minusp will check to see if the number is a negative, while the abs function will take the absolute value of the number, making it a positive.
    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

  9. #9
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Repeated Block Insertion

    Ok, thats pretty cool. Might have to start using that some.

Similar Threads

  1. 2014: Block Insertion
    By Frank Dux in forum AutoCAD General
    Replies: 4
    Last Post: 2013-06-07, 07:27 PM
  2. Loose dynamic states from sub block after insertion into master block
    By ANRCREATIONS in forum Dynamic Blocks - Technical
    Replies: 5
    Last Post: 2005-11-15, 02:41 PM
  3. Block Insertion
    By chuston.91700 in forum AutoCAD General
    Replies: 4
    Last Post: 2005-08-05, 06:29 PM
  4. Block insertion
    By jim.vipond in forum VBA/COM Interop
    Replies: 6
    Last Post: 2005-01-31, 10:15 PM
  5. Block insertion
    By bandent in forum AutoLISP
    Replies: 1
    Last Post: 2005-01-25, 12:38 PM

Posting Permissions

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