INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VBA circles extrusion

VBA circles extrusion

(OP)
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

RE: VBA circles extrusion

(OP)
Nevermind. Problem solved!

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

RE: VBA circles extrusion

What was the answer?

RE: VBA circles extrusion

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close