gaplek Posted August 22, 2008 Posted August 22, 2008 Hi. According to the AutoCAD 2006 VBA, in creating cylinder should lies in a plane parallel to the WCS XY plane. It can use this command : [font=TheSansMonoCondensed-SemiLight]Set 3DSolidObject = Object.AddCylinder(CylinderCenter, Radius, Height)[/font] how if we want to make cylinder in other direction, example: cylinder lies in a plane parallel to the WCS XZ plane? thank you Quote
SEANT Posted August 22, 2008 Posted August 22, 2008 The answer to your question may vary depending on what exactly you plan to do with your routine. The most general method to orient the cylinder would be: Sub OrientCylinder() Dim SolidObject As Acad3DSolid Dim CylinderCenter(0 To 2) As Double Dim Radius As Double Dim Height As Double Dim dblAngle As Double Dim dblPivot(0 To 2) As Double Radius = 10# Height = 100# dblAngle = 2 * Atn(1) '90 degrees dblPivot(0) = CylinderCenter(0) + 1# 'the flat ends of the cylinder are parallel to XZ Set SolidObject = ThisDrawing.ModelSpace.AddCylinder(CylinderCenter, Radius, Height) SolidObject.Rotate3D CylinderCenter, dblPivot, dblAngle End Sub For something a bit more interactive (i.e., you want the user to pick a point and have the cylinder created with respect to the current UCS) you will have to use a combination of .GetUCSMatrix and .TransformedBy methods. Another scenario may be that you have numerous lines, a wire frame for a truss system perhaps, to which you would like to align tubular members. That problem may be best addressed with: Set 3DSolidObject = Object. AddExtrudedSolidAlongPath(Profile, Path) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.