Jump to content

Recommended Posts

Posted

Hi experts , good morning and happy good fryday. Hope you're doing well,

 

I'm looking for a lisp routine which can generate blocks considering some logic.. i have attached a AutoCAD.dwg file pls help..

LISP MAKING.dwg

Posted (edited)

It can be done fairly simply but it needs your help, as the objects are on same layer this complicates things so 1st step is change dims to a new layer, 2nd step change plines to a new layer. Once this is done can just isolate 2 layers the text and the pline.

 

Its a simple look for text say ST1 then search above it for a pline, can then simply block that object with correct name.

 

So try editing the dwg making common objects on layers and code will be easy to do. Re post new dwg. 

 

If you want as blocks why not draw correct 1st up I would use a lisp to draw looks like 2 patterns, a triangle and a chamfered corner rectang, can do which way up and which corner pretty easy. As part of lisp makes block. 

 

image.png.ce0d25c5d818c8397e232a14e28cea65.png

 

The dwg should really be using lots of layers not everything on layer 0.

 

But I would have lisps for a lot of what your drafting like slots. They could be dynamic blocks, width and length, bolt holes patterns and so much more.

 

image.png.e7624ed63b059b4c2276fc550e541ae8.png

image.png

Edited by BIGAL
  • Thanks 1
  • 2 weeks later...
Posted

Hi bigal, thanks for your valuable reply...

For your information i have re layerd items and make a example of output also.. 

Pls look into the attachment..  i believe you'll definately find a way ✨✨❤️❤️

LISP MAKING R1 .dwg

Posted (edited)

This is very rough, would do a dcl with all options in one. Just makes rectangs ,triangle and champher corner.

 

; https://www.cadtutor.net/forum/topic/82771-export-part-of-drawing-as-dxf-with-individual-name-from-texts/


(defun c:gussets ( / ah:getval ah:rect ah:triangle oldsnap len len2 wid wid2 cham cham2 sc ans)

(defun AH:getval ( / ans)
  (setq vals (AH:getvalsm (list "Enter Values" "Length  " 5 4 "250" "Width" 5 4 "100" "Champfer" 5 4 "50" "Scale up" 5 4 "2")))
  (setq len (atof (nth 0 vals)) wid (atof (nth 1 vals)) cham (atof (nth 2 vals)) sc (atof (nth 3 vals)))
  (setq len2 (* sc len) wid2 (* sc wid) cham2 (* sc cham))
)

(defun AH:rect ( / pt1 pt2 )
  (setq pt1 (getpoint "\nPick lower left point "))
  (AH:getval)
  (setq pt2 (mapcar '+ pt1 (list len2 wid2 0.0)))
  (command "rectang" pt1 pt2)
  (command "dim" "VER" pt1 (mapcar '+ pt1 (list 0.0 wid2 0.0)) (mapcar '+ pt1 (list -70 wid2 0.0)) wid "exit")
  (command "dim" "Hor" pt1 (mapcar '+ pt1 (list len2 0.0 0.0)) (mapcar '+ pt1 (list 0.0 -100.0 0.0)) len "exit")
(princ)
)

(defun AH:RectChampher ( / pt1 pt2 pt3 pt4 pt5)
(AH:getval)
(setq pt1 (getpoint "\nPick lower left point "))
(setq pt2 (mapcar '+ pt1 (list len2 0.0 0.0)))
(setq pt3 (mapcar '+ pt2 (list 0.0 (- wid2 cham2) 0.0)))
(setq pt5 (mapcar '+ pt1 (list 0.0 wid2 0.0)))
(setq pt4 (mapcar '+ pt5 (list (- len2 cham2) 0.0 0.0)))
(command "pline" pt1 pt2 pt3 pt4 pt5 "c")
(command "dim" "VER" pt1 pt2 (mapcar '+ pt1 (list -70 wid2 0.0)) wid "exit")
(command "dim" "Hor" pt1 (mapcar '+ pt1 (list len2 0.0 0.0)) (mapcar '+ pt1 (list 0.0 -100.0 0.0)) len "exit")
(command "dim" "Hor" pt4 pt3 (mapcar '+ pt4 (list 0.0 100.0 0.0)) cham "exit")
(command "dim" "VER" pt3 pt4 (mapcar '+ pt3 (list 100 0.0 0.0)) cham "exit")
(princ)
)

(defun AH:triangle ( / pt1 pt2 pt3 )

(setq pt1 (getpoint "\nPick lower left point "))
(AH:getval)
(setq pt2 (mapcar '+ pt1 (list len2 0.0 0.0)))
(setq pt3 (mapcar '+ pt1 (list 0.0 wid2 0.0)))
(command "pline" pt1 pt2 pt3 "c")
(command "dim" "VER" pt1 (mapcar '+ pt1 (list 0.0 wid2 0.0)) (mapcar '+ pt1 (list -70 wid2 0.0)) wid "exit")
(command "dim" "Hor" pt1 (mapcar '+ pt1 (list len2 0.0 0.0)) (mapcar '+ pt1 (list 0.0 -100.0 0.0)) len "exit")
(princ)
)

;;;; starts here

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(setq ans (ah:butts 1 "V"  '("Please choose " "Plain rectang" "Rect-Chamfer" "Triangle")))

(command "dimstyle" "R" "Copy of DIM-40A")

(cond
((= ans "Plain rectang")(AH:rect))
((= ans "Rect-Chamfer")(AH:RectChampher))
((= ans "Triangle")(AH:triangle))
)

(setvar 'osmode oldsnap)
(princ)
)

(c:gussets)

 

 

There is so much more like hole patterns slots etc that could be generated easily.

 Multi radio buttons.lspMulti GETVALS.lsp

Edited by BIGAL

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