Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA circles extrusion

Status
Not open for further replies.

Mekanikles

Mechanical
Jan 21, 2014
20
Hi,

I'm trying to do a very simple extrusion of two circles.

What am i doing wrong?

Dim circle21, circle22 As AcadCircle
Dim cylinder21, cylinder22 As Acad3DSolid


pt1 = ThisDrawing.Utility.GetPoint(, "Pick insert point:")

D1 = Val(TextBox1.Text)
t1 = Val(TextBox2.Text)
l1 = Val(TextBox3.Text)
D2 = Val(TextBox4.Text)


Set circle21 = ThisDrawing.ModelSpace.AddCircle(pt1, D2 / 2)
Set circle22 = ThisDrawing.ModelSpace.AddCircle(pt1, D2 / 2 - t1)

Set cylinder21 = ThisDrawing.ModelSpace.AddExtrudedSolid(circle21, l1 + D1, 0)
Set cylinder22 = ThisDrawing.ModelSpace.AddExtrudedSolid(circle22, l1 + D1, 0)

Thanks in advance!

"If you're not part of the solution, you're part of the problem" - John McClane,Die hard
 
Replies continue below

Recommended for you

Nevermind. Problem solved!

"If you're not part of the solution, you're part of the problem" - John McClane,Die hard
 
Hi,

My mistake was that I was trying to do both extrusions at the same time instead of one at a time.. Also I forgot the "region" part..

Here's an easy example of my function so that everone can learn from my mistake:

Dim D1, t1, l1 As Double
Dim circle1, circle2 As AcadCircle
Dim reg1, reg2 As Variant
Dim ent(0) As AcadEntity
Dim cylinder1, cylinder2 As Acad3DSolid


pt1 = ThisDrawing.Utility.GetPoint(, "Pick insert point:")

D1 = Val(TextBox1.Text)
t1 = Val(TextBox2.Text)
l1 = Val(TextBox3.Text)

Set circle1 = ThisDrawing.ModelSpace.AddCircle(pt1, D1 / 2)
Set circle2 = ThisDrawing.ModelSpace.AddCircle(pt1, D1 / 2 - t1)

'First extrusion

Set ent(0) = circle1
reg1 = ThisDrawing.ModelSpace.AddRegion(ent)
Set cylinder1 = ThisDrawing.ModelSpace.AddExtrudedSolid(reg1(0), l1, 0)

'Second extrusion

Set ent(0) = circle2
reg2 = ThisDrawing.ModelSpace.AddRegion(ent)
Set cylinder2 = ThisDrawing.ModelSpace.AddExtrudedSolid(reg2(0), l1, 0)

reg1(0).Delete
reg2(0).Delete
circle1.Delete
circle2.Delete


"If you're not part of the solution, you're part of the problem" - John McClane,Die hard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor