Romuald Ferreux Posted March 20, 2020 Posted March 20, 2020 Dear all, I've found a lisp a long time ago to drawn a folding metal sheet in 2d. On this lisp i have change some information but today i Need your help to solved one point. In this lisp below the offset is defined according a value ( Positiv or negativ) but i try to find the solution that the user can choose wich side they want to put this offset Thx a lot for you help (defun c:blech (/ pt spt plineobj1 plineobj2) (setq a (strcase (getstring "\nChoose Layer group to load [Aluminium/Stahl/Cns] ") );strcase );setq (command "load" "variable.lsp") (cond ((= a "A") (setvar "clayer" "Al_cont")) ((= a "S") (setvar "clayer" "St_cont")) ((= a "C") (setvar "clayer" "Cn_cont")) );cond (setq *blech:Dicke* (getreal>0 "Blech-Dicke in mm: " *blech:Dicke*) spt (getpoint "\nVon Punkt: ") pt spt ) ;; Radius setzen (setvar "FILLETRAD" (* 1.2 *blech:Dicke*)) ;;basis radius 1 ;; Punkte abfragen und Pline zeichnen (while (and pt (setq pt (getpoint pt "\nnach Punkt: "))) ;; Wenn Pline vorhanden... (if plineobj1 ;; -> dann Vertex hinzufügen + Offset (progn (vla-addvertex plineobj1 (1+ (vlax-curve-getendparam plineobj1)) (vlax*point->variant (2dpoint pt)) ) ;; verrrundn (command "_FILLET" "_P" (vlax-vla-object->ename plineobj1)) ;; erst alten Offset löschen (if plineobj2 (vla-delete plineobj2) ) ;; dann neuen Offset erstellen (setq plineobj2 (car (vlax-safearray->list (vlax-variant-value (vla-offset plineobj1 (+ *blech:Dicke*))) ) ) ) ) ;; -> sonst neue Pline erstellen + Offset (setq plineobj1 (vla-addlightweightpolyline (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)) ) (vlax*pointlist2d->variant (list (2dpoint spt) (2dpoint pt)) ) ) plineobj2 (car (vlax-safearray->list (vlax-variant-value (vla-offset plineobj1 (+ *blech:Dicke*))) )) ) ) ) ;; and Funktion bricht Evaluierung ab, wenn ein Argument nil (if nicht erforderlich !) (and plineobj1 plineobj2 ;; schließen mit Pedit (beide Plines mit großem Fuzzyabstand verbinden) (command "_PEDIT" "_M" ; mehrere Objekte (vlax-vla-object->ename plineobj1) (vlax-vla-object->ename plineobj2) "" ; Ende Objektwahl "_J" ; Verbinden "_J" ; Verbindungstyp "_A" ; Hinzufügen (1+ *blech:Dicke*) ; Fuzzy (+1 zur Sicherheit) "S" "" ) ) (setq *s* (strcase (getstring "\nSchraffür erseztzen [J/N] ") );end strcase );setq (cond ((= *s* "J")(bschraffur)) ((= *s* "N")(princ)) ),endcond (princ) ) ;;;-------------------------------- ;;; GETREAL>0 - getreal ohne Null/negativ ;;; Anfragetext,Vorgabe (Zahl) ;;;-------------------------------- (defun getreal>0 (anfrage vorgabe) (initget (+ 2 4)) (cond ((getreal (strcat "\n" anfrage " <" (if (numberp vorgabe) (rtos vorgabe 2 (getvar "LUPREC")) "" ) ">: " ) ) ) (t (float vorgabe)) ) ) ;;;--------------------------------- ;;; Wandelt 2D-Punktliste in Variant um ;;;--------------------------------- (defun vlax*pointlist2d->variant (ptlist / arrayspace sarray) (setq arrayspace (vlax-make-safearray vlax-vbdouble (cons 0 (- (* 2 (length ptlist)) 1)) ) ) (setq sarray (vlax-safearray-fill arrayspace (apply 'append ptlist))) (vlax-make-variant sarray) ) ;;;--------------------------------- ;;; Wandelt Punkt in Variant um ;;;--------------------------------- (defun vlax*point->variant (pt / arrayspace sarray) (setq arrayspace (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt) 1))) ) (setq sarray (vlax-safearray-fill arrayspace pt)) (vlax-make-variant sarray) ) ;;;--------------------------------- ;;; Punkt in 2D-Punkt wandeln ;;;--------------------------------- (defun 2dpoint (point) (list (car point) (cadr point))) ;;;--------------------------------- ;;; Schraffur ;;;--------------------------------- (defun bschraffur(/ LayerList) (initdia) (cond ((= a "A") (setq *bs* "ANSI32") (setvar "clayer" "Al_Hatch") ) ((= a "S") (setq *bs* "ANSI31") (setvar "clayer" "St_Hatch") ) ((= a "C") (setq *bs* "ANSI34") (setvar "clayer" "Cn_Hatch") ) ),endcond (command "_hatch" "E" *bs* "1" "0" "S" (vlax-vla-object->ename plineobj1) "" );command (command "ucs" "") (princ) ) Quote
Roy_043 Posted March 21, 2020 Posted March 21, 2020 (edited) Source of the code: http://ww3.cad.de/foren/ubb/Forum145/HTML/002643.shtml Edited March 21, 2020 by Roy_043 Quote
Romuald Ferreux Posted March 23, 2020 Author Posted March 23, 2020 Hi Roy_043, Thx for you share this is exactly this script but my Problem is this value: (variant-value (vla-offset plineobj1 (- *blech:Dicke*))) I dont want to fix offset orientation and prefer that the user choose on the screen Thx a lot Cheers Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.