Jump to content

Lisp to drawn a metal sheet


Recommended Posts

Posted

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)
)

 

 

 

 

Posted

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

 

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...