Author Topic: How to Code this Lisp  (Read 1209 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
How to Code this Lisp
« on: June 07, 2023, 10:28:35 AM »
Hi All,

I am making shop drawing for HCS (Hollow Core Slab)
It Comes as Polyline with/without cutout and with/without opening. As image
I am wondering if one of programmer helps me to code this lisp.

Thanks in advance.

ribarm

  • Gator
  • Posts: 3309
  • Marko Ribar, architect
Re: How to Code this Lisp
« Reply #1 on: June 07, 2023, 11:08:30 AM »
I don't know for hollow part(s), but QDIM command would be just fine for boundary(ies) of shape...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

BIGAL

  • Swamp Rat
  • Posts: 1434
  • 40 + years of using Autocad
Re: How to Code this Lisp
« Reply #2 on: June 07, 2023, 08:19:20 PM »
This question was asked somewhere else. Not an easy problem to solve.

I did something trying to find but it was not a window and do all, but rather a pick pick style. Looking at bottom dims would be a do bottom "B" option.

PICK PICK  PICK  PICK  PICK PICK  then enter does all dims
PICK  PICK  PICK  then enter  does 2 dims
PICK PICK  then enter does overall
Enter exits

A single dim line would be PICK PICK  PICK  PICK  PICK PICK  then enter does all dims then ENTER to exit

It recognises the XY of the points so does a sort to reorganize for dim points, the gap and offset spacing from object was hard coded. Its about repeating rows/columns of dims form pick points based on 4 sides.

I have to edit this but need a dwg to get the correct Dim style and offsets etc. This was done for 200 off.

Code: [Select]
; https://www.cadtutor.net/forum/topic/77391-how-can-i-modify-this-code-to-allow-me-to-select-a-base-point-as-basis/
; Dimensions a shape with a 200 offset for 4 sides Right Left Top Bottom.
; By AlanH May 2023

(defun c:dim200 ( / dr200 dl200 db200 dt200 lst ans)

(defun dr200 ( / pt1 pt2 x lst2 j pt3)
(setq lst2 '())
(foreach pt lst
(setq lst2 (cons (cadr pt) lst2))
)
(setq X (car (vl-sort lst2 '>)))
(setq pt3 (list (+ x 200.) (cadr (car lst))))
(setq x (length lst))
(setq j 0)
(setvar 'osmode 0)
(repeat (- x 1)
(command "dim" "ver" (nth j lst) (nth (1+ j) lst) pt3 "" "exit")
(setq j (1+ j))
)
(setvar 'osmode oldsnap)
(princ)
)

(defun dl200 ( / pt1 pt2 x lst2 j pt3)
(setq lst2 '())
(foreach pt lst
(setq lst2 (cons (car pt) lst2))
)
(setq X (car (vl-sort lst2 '<)))
(setq pt3 (list (- x 200.) (cadr (car lst))))
(setq x (length lst))
(setq j 0)
(setvar 'osmode 0)
(repeat (- x 1)
(command "dim" "ver" (nth j lst) (nth (1+ j) lst) pt3 "" "exit")
(setq j (1+ j))
)
(setvar 'osmode oldsnap)
(princ)
)

(defun dt200 ( / pt1 pt2 y lst2 j pt3)
(setq lst2 '())
(foreach pt lst
(setq lst2 (cons (cadr pt) lst2))
)
(setq Y (car (vl-sort lst2 '>)))
(setq pt3 (list (car (car lst)) (+ y 200.) ))
(setq x (length lst))
(setq j 0)
(setvar 'osmode 0)
(repeat (- x 1)
(command "dim" "hor" (nth j lst) (nth (1+ j) lst) pt3 "" "exit")
(setq j (1+ j))
)
(setvar 'osmode oldsnap)
(princ)
)

(defun db200 ( / pt1 pt2 y lst2 j pt3)
(setq lst2 '())
(foreach pt lst
(setq lst2 (cons (cadr pt) lst2))
)
(setq Y (car (vl-sort lst2 '<)))
(setq pt3 (list (car (car lst)) (- y 200.) ))
(setq x (length lst))
(setq j 0)
(setvar 'osmode 0)
(repeat (- x 1)
(command "dim" "hor" (nth j lst) (nth (1+ j) lst) pt3 "" "exit")
(setq j (1+ j))
)
(setvar 'osmode oldsnap)
(princ)
)

;;;;;;; starts here

(setq oldsnap (getvar 'osmode))
(setq lst '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
)
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(setq ans (ah:butts 1 "V" '("Choose a side" "Right" "Left" "Top" "Bottom")))
(cond
((= ans "Right")(dr200))
((= ans "Left")(dl200))
((= ans "Top")(dt200))
((= ans "Bottom")(db200))
)
(setvar 'osmode oldsnap)
(princ)
)
Is this helpful to you Waffle slabs.

« Last Edit: June 07, 2023, 08:34:35 PM by BIGAL »
A man who never made a mistake never made anything

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2151
  • class keyThumper<T>:ILazy<T>
Re: How to Code this Lisp
« Reply #3 on: June 08, 2023, 04:25:37 AM »

From my experience, automated dimensioning of objects of this nature require an intimate understanding of how the item is manufactured.

Sometimes Ordinate dimensions are best ( or part ordinate )
Sometomes features should be dimensioned to their center.
Sometimes key dimensions related to associated attachments should be dimensioned.

Automation must be drived (or at least guided) by requirements.


Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

dexus

  • Bull Frog
  • Posts: 211
Re: How to Code this Lisp
« Reply #4 on: June 08, 2023, 07:45:23 AM »
Maybe dpl.lsp found on autolisp-exchange.com will help or at least make a good place to start.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to Code this Lisp
« Reply #5 on: June 19, 2023, 12:52:34 AM »
Thanks dexus
very close to my needs

Maybe dpl.lsp found on autolisp-exchange.com will help or at least make a good place to start.