View Full Version : Command for box
Hi,
I'm trying to use the command function to insert a box. If I want a box with sides parallel to the coordinate system axis X and Y, I can use the following expression without any problems:
(command "_.box"
"c" '(0 0) ;center
"l" 4 ;length
5 ;width
2 ;height
)
Unfortunately, all my efforts to write a command expression that creates a box that is _not_ aligned with the axis X and Y failed, although it is trivial to do that using point and click.
Please, what is the trick?
Thanks in advance,
António Leitão.
Mr Cory
2007-10-15, 03:56 AM
Try this;
(defun c:bx ()
(command "_.box" "c" "0,0,0" "l" "4" "5" "2")
(princ))
Try this;
(defun c:bx ()
(command "_.box" "c" "0,0,0" "l" "4" "5" "2")
(princ))
Your suggestion is no different than mine. It still can't create a box that is _not_ aligned with the axis. Or I'm I misunderstanding your solution?
Best regards,
António Leitão.
H'Angus
2007-10-15, 12:01 PM
Your suggestion is no different than mine. It still can't create a box that is _not_ aligned with the axis. Or I'm I misunderstanding your solution?
Best regards,
António Leitão.
Can you not just add a rotate or align previous command to the end?
d_m_hopper
2007-10-15, 01:59 PM
Can you not just add a rotate or align previous command to the end?
not sure how align works in 3D but I suppose you could could use entlast so that the box you created is selected automatically
(defun c:bx ()
(command "_.box" "c" "0,0,0" "l" "4" "5" "2")
(princ)
(setq ent (entlast))
(command "_.align" ent"")
)
when done you need to pick the points to align the box?
Maybe this will help.
(defun c:bx (/ BoxHeight BoxLength BoxWidth Rotation StartPoint)
(setq StartPoint (getpoint "\nSpecify center of box: ")
BoxLength (getdist StartPoint "\nSpecify box length: ")
BoxWidth (getdist StartPoint "\nSpecify box width: ")
BoxHeight (getdist StartPoint "\nSpecify box height: ")
Rotation (getangle StartPoint "\nSpecify rotation angle: ")
)
(command "_.box" "C" StartPoint "L" BoxLength BoxWidth BoxHeight)
(command "_.rotate"
(entlast)
""
"non"
Startpoint
(angtos Rotation)
)
)
Mr Cory
2007-10-15, 08:22 PM
Sorry misread the OP :Oops:
Maybe this will help.
(defun c:bx (/ BoxHeight BoxLength BoxWidth Rotation StartPoint)
(setq StartPoint (getpoint "\nSpecify center of box: ")
BoxLength (getdist StartPoint "\nSpecify box length: ")
BoxWidth (getdist StartPoint "\nSpecify box width: ")
BoxHeight (getdist StartPoint "\nSpecify box height: ")
Rotation (getangle StartPoint "\nSpecify rotation angle: ")
)
(command "_.box" "C" StartPoint "L" BoxLength BoxWidth BoxHeight)
(command "_.rotate"
(entlast)
""
"non"
Startpoint
(angtos Rotation)
)
)
That seems to solve the problem. Thanks a lot!
Best regards,
António Leitão.
PS: It is strange that the command form can't provide the appropriate arguments to simulate something that can be done directly using the box command.
d_m_hopper
2007-10-16, 06:52 PM
Maybe this will help.
(defun c:bx (/ BoxHeight BoxLength BoxWidth Rotation StartPoint)
(setq StartPoint (getpoint "\nSpecify center of box: ")
BoxLength (getdist StartPoint "\nSpecify box length: ")
BoxWidth (getdist StartPoint "\nSpecify box width: ")
BoxHeight (getdist StartPoint "\nSpecify box height: ")
Rotation (getangle StartPoint "\nSpecify rotation angle: ")
)
(command "_.box" "C" StartPoint "L" BoxLength BoxWidth BoxHeight)
(command "_.rotate"
(entlast)
""
"non"
Startpoint
(angtos Rotation)
)
)
what does this mean?
""
"non"
Startpoint
(angtos Rotation)
)
)
RobertB
2007-10-16, 07:05 PM
Use the None OSnap override, provide the point, convert the angle from radians into whatever angular units are in use.
However, the (angtos) will result in bugs, due to unit precision. Far better would be to mathmatically convert the units, e.g.:
(/ (* rotation 180.0) pi)
d_m_hopper
2007-10-17, 01:49 PM
Use the None OSnap override, provide the point, convert the angle from radians into whatever angular units are in use.
However, the (angtos) will result in bugs, due to unit precision. Far better would be to mathmatically convert the units, e.g.:
(/ (* rotation 180.0) pi)
thanks Robert
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.