Draw a rectangular box knowing two base center points, its width and height.

Draw a rectangular box knowing two base center points, its width and height.

Kh.mbkh
Advocate Advocate
645 Views
8 Replies
Message 1 of 9

Draw a rectangular box knowing two base center points, its width and height.

Kh.mbkh
Advocate
Advocate

Hello!

Objectif: Draw a rectangular box knowing center of two base, width and height:

Input:

- center point C1 = '(x1 y1 z1) of the first base 

- center point C2 = '(x2 y2 z2) of the second base

- Width and Height.

 

AskFor.PNG

 

As you know, BOX command asks for P1 P2 P3 and P4 points (see picture, red points), but for us the input we know are only Center1, Center2, Width and Height.

It's a geometric issue, but you may have idea to help...

Thanks!

0 Likes
Accepted solutions (2)
646 Views
8 Replies
Replies (8)
Message 2 of 9

paullimapa
Mentor
Mentor

I can get you partially there with a Square when Width=Height by using command:

POLYGON

4 sides

center is C1

Circumscribed option

Radius is Width or Height divided by 2

Then use the following command to create the BOX:

Extrude

Last

 

Direction

C1

C2

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 9

Sea-Haven
Mentor
Mentor

Your talking about a SOLID Box ? So you have distance between pt1 pt2 as the length so need width and extrusion height, so just do that use solid box command then do a rotate and move to the 2 points.

Message 4 of 9

paullimapa
Mentor
Mentor
Accepted solution

@Sea-Haven I like where you're going with this 

@Kh.mbkh see example pix below:

paulli_apa_0-1681710111865.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 9

komondormrex
Mentor
Mentor
Accepted solution

hey,

just box with width, height and depth

 

(setq center_point_1 '(-100. 150. 200.))
(setq center_point_2 '(300. -50. -400.))
(setq height 130.)
(setq width 50.)
;(command "_line" center_point_1 center_point_2 "")
(command "_rectang" "_non" (list (* -1 0.5 height) (* -1 0.5 width)) "_non" (list (* 0.5 height) (* 0.5 width)))
(setq profile_object (vlax-ename->vla-object (setq profile_ename (entlast))))
(setq divider (apply 'max (mapcar 'abs (mapcar '- center_point_1 center_point_2)))) 
(vla-put-normal profile_object (vlax-3d-point (mapcar '/ (mapcar '- center_point_1 center_point_2) (list divider divider divider))))
(vla-move profile_object (vlax-3d-point '(0 0 0)) (vlax-3d-point center_point_1)) 
(command "_extrude" profile_ename "" "_d" center_point_1 center_point_2)    
0 Likes
Message 6 of 9

Kh.mbkh
Advocate
Advocate

Thank you for your time:

I did thoses steps:

-Command box - Center (Select midpoint of Center1-Center2) - Length (Insert my length = distance between center1 and center2) - Width (Insert my width) - Then, autocad asks to insert height or 2Points, I tried both height and 2Points, but can't draw the correct box.

Thanks.

AskFor2.PNG

 

0 Likes
Message 7 of 9

paullimapa
Mentor
Mentor

You forgot the step before the Box command which is:

UCS 

ZAxis

Center1

Center2

now do the Box command sequence then for height you can pick either Center1 or Center2


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 9

Kh.mbkh
Advocate
Advocate
Good, but I may need to calculate new coordinate (In new systeme) for each point (Box center point - center1 - center2 ); because when I run Box command - center (I inserted coordinate of Box center point in old systme W-UCS) , so here "No Center found for specified point".
Maybe need to calculate new coordinate in the new UCS ?
0 Likes
Message 9 of 9

paullimapa
Mentor
Mentor

Yes all points now need to be entered in the current ucs or use lisp trans function to translate the coordinates from one ucs to another:

http://docs.autodesk.com/ACD/2013/ENU/index.html?url=files/GUID-1A316343-0B68-4DBE-8F49-B4D601CB8FCC...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes