Jump to content

Recommended Posts

Posted

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

Posted

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)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...