Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Kh.mbkh
422 Views, 8 Replies

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

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!

8 REPLIES 8
Message 2 of 9
paullimapa
in reply to: Kh.mbkh

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
Message 3 of 9
Sea-Haven
in reply to: Kh.mbkh

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
in reply to: Sea-Haven

@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
Message 5 of 9
komondormrex
in reply to: Kh.mbkh

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)    
Message 6 of 9
Kh.mbkh
in reply to: paullimapa

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

 

Message 7 of 9
paullimapa
in reply to: Kh.mbkh

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
Message 8 of 9
Kh.mbkh
in reply to: paullimapa

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 ?
Message 9 of 9
paullimapa
in reply to: Kh.mbkh

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report