Author Topic: New Lisp Routine to challenge your Mind...  (Read 3679 times)

0 Members and 1 Guest are viewing this topic.

AVCAD

  • Guest
New Lisp Routine to challenge your Mind...
« on: September 17, 2004, 02:52:37 PM »
Well maybe not...but It is certanly challenging mine..

What I want is to have a set block...and have that block inserted multiple times across a given distance...

Sounds Easy but I cant figure it out.

So far I have been able to get the first point get the second point, get the angle (0,90,180,270) and insert the correct block for that angle...but I can only get it to insert once....actually I have no clue how to repeat the insert command...But if it is repeated it needs to change the postion of the block so tha the ends meet up...in this case the length of the block is 37.75

Here is my code so far...

Code: [Select]

(defun C:race ()
(setq P1 (getpoint "Start Point: "))
(setq P2 (getdist P1 "End Point: "))
(setq A (getangle P1 "Which Direction (0,90,180,270): "))
(if (= A 0) (command "INSERT" "G:/CHI-CUSTOMCAD/BLOCKS/TECHNOLOGY/TC/raceway-r.dwg" P1 "1" "1" "0"))
(if (= A pi) (command "INSERT" "G:/CHI-CUSTOMCAD/BLOCKS/TECHNOLOGY/TC/raceway-l.dwg" P1 "1" "1" "0"))
(if (= A (/ pi 2)) (command "INSERT" "G:/CHI-CUSTOMCAD/BLOCKS/TECHNOLOGY/TC/raceway-up.dwg" P1 "1" "1" "0"))
(if (= A (* 3 (/ pi 2))) (command "INSERT" "G:/CHI-CUSTOMCAD/BLOCKS/TECHNOLOGY/TC/raceway-dwn.dwg" P1 "1" "1" "0"))


IF there a better way of coding this I would be glad to listen. Also if you know of a way to have this work with any angle I would glad to listen to that too.

CADaver

  • Guest
New Lisp Routine to challenge your Mind...
« Reply #1 on: September 17, 2004, 02:58:25 PM »
A couple of questions:

Is it a regular equidistant array?

Do you NEED 4 different blocks, or would one block with different rotation angles be sufficient?

Do you NEED multiple inserts, or would changing the X scale to the full length of the raceway be sufficient?

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
New Lisp Routine to challenge your Mind...
« Reply #2 on: September 17, 2004, 03:23:32 PM »
Code: [Select]

(repeat(fix(/(distance pt1 pt2)space))
(command "._circle" pt1 "12")
(setq pt1(polar pt1 0 space))
)


I think something like this will help
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

AVCAD

  • Guest
New Lisp Routine to challenge your Mind...
« Reply #3 on: September 17, 2004, 03:24:16 PM »
Well first..

the block is a rectangle 37.75 long and about 5.5 wide. Half of the block is hatched with a solid.

IF copied (or array'ed) the distance would ne end to end so I guess it would be and equal distance each time.

I have it set up as 4 differant blocks right now because I dont know how to let it rotate the block by itself. I would like it to be 1 block with diferant rotations though.

I am interested in the last question. Could I just creat a really small block that have multiple hatchs in it and just scale the one block to the size of the raceway? This option I think would be great.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Lisp Routine to challenge your Mind...
« Reply #4 on: September 17, 2004, 03:51:19 PM »
Not exactly but it will do the job.

Code: [Select]
(defun c:race (/ p1 ang)
  (if (and
        (setq p1 (getpoint "\nPickInsert Point: "))
        (setq ang (getangle p1 "\nPick direction: "))
      )
    (progn
      (setq ang (* 180.0 (/ ang pi)))
      (command "INSERT" "G:/CHI-CUSTOMCAD/BLOCKS/TECHNOLOGY/TC/raceway-r.dwg"
               p1 "1" "" ang)
      (command "._copybase" p1 (entlast) "")
      (while t
        (command "._pasteclip" pause)
      )
    ) ; progn
  ) ; endif
  (princ)
) ; defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Lisp Routine to challenge your Mind...
« Reply #5 on: September 17, 2004, 03:52:47 PM »
If the block already is in the drawing I use this one a lot.
Code: [Select]
(defun C:CopyR (/ EN OBJ pt)
  (prompt "Pick base point and object to copy:")
  (command "._copybase" pause pause "")
  (while t
    (command "._pasteclip" pause)
    (setq obj (entlast)); get last object
    (setq pt (cadr (grread t 1))); get insert point
    ;;  allow user to rotate
    (command "._rotate" Obj "" pt pause)
  )
  (princ)
)
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

AVCAD

  • Guest
New Lisp Routine to challenge your Mind...
« Reply #6 on: September 17, 2004, 04:03:14 PM »
well not exactly like you said....Is there away we can add a distance and insert the block over that set distance from the base point of the block to end of the block?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Lisp Routine to challenge your Mind...
« Reply #7 on: September 17, 2004, 04:23:34 PM »
Code: [Select]
(defun c:race (/ p1 ang ang2 cnt)
  (if (and
        (setq p1 (getpoint "\nPickInsert Point: "))
        (setq ang (getangle p1 "\nPick direction: "))
        (null(initget 7))
        (setq cnt (getint "\nEnter number of copies:"))
      )
    (progn
      (setq ang2 (* 180.0 (/ ang pi)))
      (command "INSERT" "G:/CHI-CUSTOMCAD/BLOCKS/TECHNOLOGY/TC/raceway-r.dwg"
               p1 "1" "" ang2)
      (command "._copybase" p1 (entlast) "")
      (repeat cnt
        (setq p1 (polar p1 ang 37.5))
        (command "._pasteclip" p1)
      )
    ) ; progn
  ) ; endif
  (princ)
) ; defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

AVCAD

  • Guest
New Lisp Routine to challenge your Mind...
« Reply #8 on: September 27, 2004, 10:21:43 AM »
Well..I just got back from Cancun and thought I would check the status on this lisp routine.

This is more of what I wanted to accomplish but....in this routine it asks how many blocks t insert....

Is there away to make it just insert the blocks across that path...with out asking how many block to use?

daron

  • Guest
New Lisp Routine to challenge your Mind...
« Reply #9 on: September 27, 2004, 06:56:48 PM »
Try measure or divide in your routine using the block feature.