NEED A LISP CREATING CUSTOM SHPE

NEED A LISP CREATING CUSTOM SHPE

archana96
Enthusiast Enthusiast
1,762 Views
16 Replies
Message 1 of 17

NEED A LISP CREATING CUSTOM SHPE

archana96
Enthusiast
Enthusiast

HI Guys i need a lisp for my work because  i will save my time for refrence i attacheed  the image so i will give the only input ABC.........   NEED TO CREATE THAT DAIGRAM EACH ONE IS DIFRENT SO NEED SAPIRATE COMMAND.....

archana96_0-1749728464166.png

 

0 Likes
Accepted solutions (1)
1,763 Views
16 Replies
Replies (16)
Message 2 of 17

Sea-Haven
Mentor
Mentor

This is a good exercise to start learning lisp, rather than people supplying an answer.

 

For the 1st shape you just need 3 things length, width & thickness.

 

Here is an example for shape 1 a rectang.

; draw rectang
(defun c:s1  / len wid pt1 pt2 pt3 pt4)
(setq pt1 (getpoint "\nPick a point "))
(setq len (getreal "\nEnter length "))
(setq wid (getreal "\nEnter width "))
(setq pt2 (polar pt1 0.0 len))
(setq pt3 (polar pt2 (/ pi 2.) wid))
(setq pt4 (polar pt3 pi len))
(command "pline" pt1 pt2 pt3 pt4 "c")
(princ)
)

So you should be able to work out your "U" shape from the code. Have a go if stuck post your code here.

0 Likes
Message 3 of 17

archana96
Enthusiast
Enthusiast

its giving only rectangular shape

 

0 Likes
Message 4 of 17

Moshe-A
Mentor
Mentor

@archana96 ,

 

you can do it by your own with dynamic blocks.

 

Moshe

0 Likes
Message 5 of 17

Kent1Cooper
Consultant
Consultant

The blue ones would not be difficult to program.  But the magenta one would be harder because of the change of direction of the bends:

Kent1Cooper_0-1749809846847.png

With the A and C/D dimensions being to the outside corners on opposite sides of the sheet, and with the bend angles varying with the A/B/C relationship, calculating vertex locations would be very challenging.

Is that sheet thickness dimension an F that just looks like an E because it's too close to the dimension line tail?  Or do you actually have two E dimensions that cannot be the same?

Kent Cooper, AIA
0 Likes
Message 6 of 17

Sea-Haven
Mentor
Mentor

What I was suggesting is have a go at writing the code your self, there is plenty of people here who could do your code and after all this is a volunteer forum we give our time for free, its not a write this for me service.

 

I showed the code needed to draw a box, if you look at it carefully you can see it uses the polar command to work out the next point, it then draws the shape using a pline with multiple points.

 

So your "U" shape will need 8 points using simple geometry of angles 0.0. (/ pi 2), pi, (* pi 1.5). and look at the values you have for length and width.

 

Again as pointed out by @Kent1Cooper you just need to work out all the points for a more complex shape. I would start at the midpoint of the "A" and go left and right.

 

In the code above you load the lisp and type S1 for "shape 1" so your "U" is S2, C section is S3, hat section is S4. As a side comment there is steel sections out there which have a huge range of predefined sections or you can edit the section data to suit your needs, think Angles, UB, UC, tubes and so on.

 

 

0 Likes
Message 7 of 17

Moshe-A
Mentor
Mentor

@archana96  hi,

 

Attached profiles.zip file contains 2 files:

1. profiles.vlx

2. profiles.csv (data file)

 

Because there are many properties you have to set at each insert, the idea here is to create an excel file (csv)

serve as profiles library so lets look at the data file format:-

in this example it contains 3 rows each represent a U profile.

 

The first row is header.

first column 'type' (p1, p2, p3)

second column call 'insert' can have 4 values, switchs on,off or yes,no meaning yes to insert the profile or not.

third column call 'mirror' same 4 values, switchs on,off yes,no meaning yes to apply mirror or not.

forth column call 'rotation' degrees for setting rotation angle.

the rest column A, B, C, D, E, F dimension as specified in your picture.

note:

in third profile you specified 'F' as width but in the first 2 profiles 'D' is the width so i change it 😀

 

after loading the the lisp key:

Command: PROFILES

pick data file

profile "px" insertion point:  <specify point>

 

The program read data file in than goes to check cells validation and if invalid data found you will be notify.

than you will get your profile.

 

you can have many data files (pro1, pro2 ....)

you can add as many rows (records)  as needed [as long their type is 3: p1, p2, p3]

with 'insert' column you control which profile to insert. if two rows (or more) have insert=yes, you will get two profiles.

 

enjoy

Moshe

 

MosheA_1-1750107746602.png

 

 

 

 

0 Likes
Message 8 of 17

Sea-Haven
Mentor
Mentor

@Moshe-A a really good idea using excel maybe add size to the types. An extra column

no need for thickness as shapes are defined for thickness by name if need thickness add to name eg ANGLE, has multi thickness for same size.

And so on.

P1 12060

P1 180100

P2 12075

0 Likes
Message 9 of 17

Moshe-A
Mentor
Mentor

@Sea-Haven ,

 

thanks you, lets see what OP has to say

 

 

0 Likes
Message 10 of 17

Kent1Cooper
Consultant
Consultant

I assume I know the answer, but I will ask anyway:

Is there any chance you would be able to define those dimensions all on one side of the profile?

Kent1Cooper_0-1750178971128.png

The A and B dimensions here are on the lower side, rather than what I think is the intent in your image, with the A being on the upper side and the B being from lower to upper -- the vertical extremes.

If it can be specified in this way, programming would be quite simple, and it would just be a matter of drawing the underside edge as a Polyline, Offsetting it by the sheet thickness, and closing the ends.

With what I think you intend, my B could be calculated by subtracting the sheet thickness from your B.  But calculating my A from your A would be difficult to do with precision at various different diagonal directions.

Kent Cooper, AIA
0 Likes
Message 11 of 17

Kent1Cooper
Consultant
Consultant
Accepted solution

@Kent1Cooper wrote:

....

With the A and C/D dimensions being to the outside corners on opposite sides of the sheet, and with the bend angles varying with the A/B/C relationship, calculating vertex locations would be very challenging.

....


But I figured out the relationship and the needed applications of Pythagoras's theorem and a little trigonometry, to work it out.  See the attached test.lsp and its TEST command.  Here are the lengths and locations contained in the variables [with very exaggerated material thickness to make things clearer]:

Kent1Cooper_0-1750185794250.png

It draws it [just the magenta part, not all the points and references] in the middle of the screen.  It ends up with vertices at the midpoints of both edges of the top surface, just because it was easier, but those could be eliminated with some more code.  It could also be made to do things like remember your values to offer them as defaults on subsequent use, and could use *error* handling and Undo begin/end wrapping, etc.  But first see whether it does what you want.

Kent Cooper, AIA
0 Likes
Message 12 of 17

Sea-Haven
Mentor
Mentor

@Kent1Cooper I did find this "Top Hat" It just references via height and width, so need a manufactures details for all the values as you showed in previous post.

SeaHaven_0-1750205569777.png

SeaHaven_1-1750205692633.png

 

0 Likes
Message 13 of 17

archana96
Enthusiast
Enthusiast

i tried the middle one that like c shape with lip. 

 

 

this i created code but its give many issues for some times gives better shape some times not come what i need for example i give a image of i taken input(added in middle of shape)  and what is came output shape 

archana96_0-1750307899902.png

and i attached the code for your reference..

 

(defun c:testbeam ()
;; Get User Inputs
(setq lb (getdist "\nLength of Beam : ")) ;; Beam Length
(setq hb (getdist "\nHeight of Beam : ")) ;; Beam Height
(setq lp (getdist "\nLip Length : ")) ;; Lip Length
(setq wt (getdist "\nThickness : ")) ;; Thickness

;; Get Insertion Point
(setq ip (getpoint "\nInsertion Point : ")) ;; Insertion Point

;; Polar Calculations
(setq p2 (polar ip (dtr 90.0) lp))
(setq p3 (polar p2 (dtr 180.0) lb))
(setq p4 (polar p3 (dtr 270.0) hb))
(setq p5 (polar p4 (dtr 0.0) lb))
(setq p6 (polar p5 (dtr 90.0) lp))
(setq p7 (polar p6 (dtr 180.0) wt))
(setq p8 (polar p7 (dtr 270.0) (- lp wt)))
(setq p9 (polar p8 (dtr 180.0) (- lb (* 2 wt))))
(setq p10 (polar p9 (dtr 90.0) (- hb (* 2 wt))))
(setq p11 (polar p10 (dtr 0.0) (- lb (* 2 wt))))
(setq p12 (polar p11 (dtr 270.0) (- lp wt)))

;; Draw Polyline with Valid Points
(if (and p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12)
(command "Pline" ip p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 "c")
(princ "\nError: Invalid points detected.")
)

(princ) ;; Load cleanly
)

;; Function to Convert Degrees to Radians
(defun dtr (x) (* pi (/ x 180.0)))

(princ)

0 Likes
Message 14 of 17

archana96
Enthusiast
Enthusiast

its worked

0 Likes
Message 15 of 17

Kent1Cooper
Consultant
Consultant

@archana96 wrote:

... but its give many issues for some times gives better shape some times not ....


Do you sometimes do it with any running Object Snap mode(s) turned on?

Kent Cooper, AIA
0 Likes
Message 16 of 17

Sea-Haven
Mentor
Mentor

Glad you got shape to work, here is some help, as you are mainly drawing horizontal or vertical you can declare the angle as variables, as you have done already converting to radians but this way may be easier. Once you get the hang of using radians other angles like 45 135 225 315 etc can be done same way. You can use your dtr and copy and paste the answer into your code for other angles.

(defun c:testbeam ( / pt1 pt2 pt3 pt4 oldsnap)

(setq oldsnap (getvar 'osmode)) ; get osnaps
(setvar 'osmode 0) ; turn off snaps

(setq a90  (/ pi 2.0) a270 (* pi 1.5)) ; angles use 0.0 90 270 180 = pi
;; Get User Inputs
(setq lb (getdist "\nLength of Beam : ")) ;; Beam Length
(setq hb (getdist "\nHeight of Beam : ")) ;; Beam Height
(setq lp (getdist "\nLip Length : ")) ;; Lip Length
(setq wt (getdist "\nThickness : ")) ;; Thickness

;; Get Insertion Point
(setq ip (getpoint "\nInsertion Point : ")) ;; Insertion Point

;; Polar Calculations
(setq p2 (polar ip a90 lp))
(setq p3 (polar p2 pi lb))
(setq p4 (polar p3 a270 hb))
(setq p5 (polar p4 0.0 lb))
(setq p6 (polar p5 a90 lp))
(setq p7 (polar p6 pi wt))
(setq p8 (polar p7 a270 (- lp wt)))
(setq p9 (polar p8 pi (- lb (* 2 wt))))
(setq p10 (polar p9 a90 (- hb (* 2 wt))))
(setq p11 (polar p10 0.0 (- lb (* 2 wt))))
(setq p12 (polar p11 a270 (- lp wt)))

;; Draw Polyline with Valid Points
(if (and p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12)
(command "Pline" ip p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 "c")
(princ "\nError: Invalid points detected.")
)
(setvar 'osmode oldsnap)
(princ) ;; Load cleanly
)

 

You can look at a more advanced way to enter values, using a DCL. get a bit more experience then can help you make the dcl's. This one was produced by using a Library lisp that was written to suit your type of application, as it makes a new dcl as required matching inputs.

SeaHaven_0-1750380043007.png

 

0 Likes
Message 17 of 17

Sea-Haven
Mentor
Mentor

Looking into this task you may be reinventing the wheel have a look at this very extensive steel shapes library, the shapes you want may be there already. they use a database of predefined sizes, a DIM file, there has been users posting here for subtle changes to the shapes as to meet their country shape.

 

This is an example of C purlins data.

("C100-10" 102 51 12.5 1.0 5)
("C100-12" 102 51 13.0 1.2 5)
("C100-15" 102 51 14.0 1.5 5)
("C100-19" 102 51 15.0 1.9 5)
("C150-10" 152 64 14.5 1.0 5)
("C150-12" 152 64 15.0 1.2 5)
("C150-15" 152 64 16.0 1.5 5)
("C150-19" 152 64 17.0 1.9 5)
("C150-24" 152 64 18.5 2.4 5)
("C200-15" 203 76 16.0 1.5 5)
("C200-19" 203 76 19.5 1.9 5)
("C200-24" 203 76 21.0 2.4 5)
("C250-19" 254 74 19.0 1.9 5)
("C250-24" 254 74 20.5 2.4 5)
("C300-24" 300 96 28.0 2.4 5)
("C300-30" 300 96 31.5 3.0 5)
("C350-30" 350 125 30.0 3.0 5)

 

0 Likes