Is there a way to automate a coil strip layout for a rectangular blank???
The input to the drawing would be the size of the rectangle.
|
Is there a way to automate a coil strip layout for a rectangular blank???
The input to the drawing would be the size of the rectangle.
Hi rhallOriginally Posted by rhall.72202
Maybe there is what you need
f.
Code:(defun C:test1 (/ pnt1 pnt2 pnt3) (setvar "osmode" 512) (setq pnt1 (trans (getpoint "\nPick start point of coil strip\n") 0 1)) (setvar "osmode" 128) (setq pnt2 (getpoint pnt1 "\nPick end point of coil strip\n")) (setvar "osmode" 0) (setq pnt3 (polar pnt1 (angle pnt1 pnt2)(/ (distance pnt1 pnt2) 2))) (command "_.pline" pnt1 "W" "0" "0" "A" "A" 70. pnt3 pnt2 "") (princ) ) (C:test1)
If that doesn't do it for you, this thread has a few more options.
That is a good routine, however, I am looking to also add the rectangles.
The result should be the picture I have provided.
This would be good for making strip layouts of rectangular blanks from master coils.
Hi rhallOriginally Posted by rhall.72202
Sorry I answer you too late
Try this version soluted with ActiveX
Change it by suit and spell all prompts
Tested on A2005 only
Thank you
f.
Code:;; error handler (defun bul-err (msg) (if (vl-position msg '("console break" "Function cancelled" "quit / exit abort" ) ) (princ "Error!") (princ msg) ) (while (> (getvar "cmdactive") 0) (command)) (command "._undo" "_end") (command "._u") (setq *error* olderror) (princ) ) ;; create safearray of points (defun safe-points (lst / pt_list points) (setq pt_list (apply 'append lst)) (setq points (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (1- (length pt_list))) ) pt_list ) ) ) (vl-load-com) (prompt "\n *** Type DSTP to execute *** \n") ;; main programm ;; (defun C:dstp (/ *error* acsp adoc appd app_point blank cnt cor_list bul-err len mod_rect num olderror p1 p2 p3 p4 pt_list rect rect_list step wid ) (or adoc (setq adoc (vla-get-activedocument (vlax-get-acad-object) ) ) ) (or appd (setq appd (vla-get-application adoc))) (or acsp (setq acsp (vla-get-block (vla-get-activelayout adoc) ) ) ) (command "._undo" "_end") (command "._undo" "_mark") (setq olderror *error*) (setq *error* bul-err) ;; calculation rectangle vertices (setq num 5 ;(getint "\nNumber of rectangles\n") len 20. ;(getdist "\nEnter lenght of rectangle\n") wid 12. ;(getdist "\nEnter width of rectangle\n") blank 5. ;(getdist "\nEnter space lenght between rectangles\n") p1 (trans (getpoint "\nSpecify lower right point of rectangle\n") 1 0 ) p2 (trans (list (car p1) (+ (cadr p1) wid)) 1 0) p3 (trans (list (- (car p2) len) (cadr p2)) 1 0) p4 (trans (list (car p3) (cadr p1)) 1 0) step (+ len blank) cor_list (list p4 p1 p2 p3) cnt -1 ) (repeat num (setq pt_list (mapcar (function (lambda (x) (mapcar '+ x (list (* cnt step) 0.0 0.0)) ) ) cor_list ) pt_list (safe-points pt_list) rect (vla-addpolyline acsp pt_list) cnt (1- cnt) ) (vlax-put-property rect 'Closed :vlax-true) (setq rect_list (cons rect rect_list)) ) (setq mod_rect (car rect_list)) (setq app_point (trans (list (+ (car p1) (+ (* cnt len) (* (1+ cnt) blank)) ) (+ (cadr p1) (/ wid 2)) ) 1 0 ) app_point (vlax-3d-point app_point) ) (vla-appendvertex mod_rect app_point) (vla-setbulge mod_rect 4 0.25) (vla-setbulge mod_rect 3 -0.25) (mapcar 'vlax-release-object rect_list) (vla-zoomextents appd) (vla-regen adoc acactiveviewport) (setq *error* olderror bul-err nil ) (command "._undo" "_end") (princ) ) ;TesT:(C:dstp)
Last edited by fixo; 2005-09-07 at 01:30 PM.
Thats almost it........I would like to be able to specify the size of the rectangle.
I am using 2006 and all I get asked for is to pick the lower corner of the rectangle.
I hope this helps.Originally Posted by rhall.72202
It has no error control. It will only place it within the WCS, similar to the rectangle command. You can only pick the lower left and the upper right to have it correctly work. If you choose to pick in a different order, it will not draw the arcs correctly.Code:(defun C:TEST (/ DTR ANG LL LM LML LMR LR OSMD THIRDS UL UML UMR UR) (defun DTR (A) (* pi (/ A 180.0))) ;;; utility to convert decimal degrees to radians (setq LL (getpoint "\nSpecify Lower Left Corner: ") UR (getcorner LL "\nSpecify Upper Right Corner: ") UL (list (car LL) (cadr UR)) LR (list (car UR) (cadr LL)) THIRDS (* (/ 1.0 3.0) (distance LL LR)) ANG (angle LL LR) LML (polar LL ANG THIRDS) LMR (polar LML ANG THIRDS) UML (polar UL ANG THIRDS) UMR (polar UML ANG THIRDS) LM (polar LL (+ (DTR 90.0) ANG) (* 0.5 (distance LL UL))) ) (setq OSMD (getvar "osmode")) (setvar "osmode" 0) (command "pline" LL LR UR UL "") (command "pline" LML UML "") (command "pline" LMR UMR "") (command "arc" LL "e" LM "a" "90.0") (command "arc" UL "e" LM "a" "90.0") (setvar "osmode" OSMD) (setq OSMD nil) )
Each vertical line is drawn one third the distance of the lower horizontal line from each end.
The arcs are drawn with a start, end, and angle configuration. The angle is always 90%%d.
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
That is definately what I need. Thanks for your help.
You're welcome. Sorry for some of the assumptions. I wasn't sure on some of your requirements. A little description of those may help in the future.Originally Posted by rhall.72202
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