×
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!
  • Students Click Here

*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.

Students Click Here

Jobs

AddExtrudedSolidAlongPath Automation Control from VB

AddExtrudedSolidAlongPath Automation Control from VB

AddExtrudedSolidAlongPath Automation Control from VB

(OP)
I get a type mismatch error with the following code:
Dim noOfPoints As Integer: noOfPoints = 5
ReDim P(0 To noOfPoints * 2 - 1) As Double
P(0) = 0#: P(1) = 0#
P(2) = L: P(3) = 0#
P(4) = L: P(5) = Th
P(6) = 0#: P(7) = Th
P(8) = 0#: P(9) = 0# 'a closed polyline
Dim ObjectList(0 To 0) As Object 'in this case an array length of 1
Set ObjectList(0) = acadApp.ActiveDocument.ModelSpace.AddLightWeightPolyline(P)

Dim Regions As Variant
Regions = acadApp.ActiveDocument.ModelSpace.AddRegion(ObjectList)

Dim PointsArray(0 To 5) As Double
PointsArray(0) = 0: PointsArray(1) = 0: PointsArray(2) = 0
PointsArray(3) = 0: PointsArray(4) = 0: PointsArray(5) = 6
Dim anObj As Object
Set anObj = acadApp.ActiveDocument.ModelSpace.AddExtrudedSolidAlongPath(Regions, PointsArray)

I can perform the task from the ACAD R14 command line but why do I get a MisMatch error on the last statement?

RE: AddExtrudedSolidAlongPath Automation Control from VB

RetVal = ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(Regions, tempPolyLine)

Second argument has to be PolyLine, Circle, Ellipse, Spline or Arc.
Maybe if a tempPolyline is produced from the pointsarray, then it will work.

RE: AddExtrudedSolidAlongPath Automation Control from VB

Hi again. The following works. Use Regions(0) as arguments. Hope this is useful.
www.homescript.com

Sub myExtrude()
 'I get a type mismatch error with the following code:
 'Solution: use Regions(0) as argument
 
 Dim noOfPoints As Integer: noOfPoints = 5
 ReDim P(0 To noOfPoints * 2 - 1) As Double
 L = 10: Th = 10
 P(0) = 0#: P(1) = 0#
 P(2) = L: P(3) = 0#
 P(4) = L: P(5) = Th
 P(6) = 0#: P(7) = Th
 P(8) = 0#: P(9) = 0# 'a closed polyline
 Dim ObjectList(0 To 0) As Object 'in this case an array length of 1
 'Set ObjectList(0) = AcadApplication.ActiveDocument.ModelSpace.AddLightWeightPolyline(P)
 Set ObjectList(0) = ThisDrawing.ModelSpace.AddLightWeightPolyline(P)
 Dim Regions As Variant
 Regions = ThisDrawing.ModelSpace.AddRegion(ObjectList)
 Regions(0).Color = acRed

 Dim PointsArray(0 To 5) As Double
 PointsArray(0) = 0: PointsArray(1) = 0: PointsArray(2) = 0
 PointsArray(3) = 0: PointsArray(4) = 0: PointsArray(5) = 500
 Dim anObj As Object
 'Set anObj = AcadApp.ActiveDocument.ModelSpace.AddExtrudedSolidAlongPath(Regions, PointsArray)
 Dim tempPolyline As Acad3DPolyline
 Set tempPolyline = ThisDrawing.ModelSpace.Add3DPoly(PointsArray)
 Set anObj = ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(Regions(0), tempPolyline)
 ThisDrawing.ActiveViewport.ZoomAll
End Sub

RE: AddExtrudedSolidAlongPath Automation Control from VB

(OP)
OK Thanks. I wish I would have posted several days ago and avoided online documentation grief.

Dim tempPolyline As Acad3DPolyline 'your code
Dim tempPolyline As Object 'my code
How do you get away with this?
I'm using VB6 and Acad R16. I loaded the Acad.tlb and it shows as a reference.

RE: AddExtrudedSolidAlongPath Automation Control from VB

I felt the uncontrollable need to clean up the code a bit.

Sub myExtrude()
'declarations
'note LWPolyObj only has 4 points on a 4 sided object
 Dim noOfPoints As Integer: noOfPoints = 4
 Dim regionObj As Variant
 Dim PointsArray(0 To 5) As Double
 Dim SolidObj As Acad3DSolid
 Dim tempPolyline As Acad3DPolyline
 Dim LWPolyObj(0 To 0) As AcadEntity
 ReDim P(0 To noOfPoints * 2 - 1) As Double
 
 ' initializations
 l = 10: Th = 10
 
 PointsArray(0) = 0: PointsArray(1) = 0: PointsArray(2) = 0
 PointsArray(3) = 0: PointsArray(4) = 0: PointsArray(5) = 500
 
 P(0) = 0#: P(1) = 0#
 P(2) = l: P(3) = 0#
 P(4) = l: P(5) = Th
 P(6) = 0#: P(7) = Th
 
'create LWPolyObj for regionObj
 Set LWPolyObj(0) = ThisDrawing.ModelSpace.AddLightWeightPolyline(P)

'Use the closed property of the LWPolyObj
 LWPolyObj(0).Closed = True
 
'create regionObj using LWPolyObj list
 regionObj = ThisDrawing.ModelSpace.AddRegion(LWPolyObj)

'create a path to follow
 Set tempPolyline = ThisDrawing.ModelSpace.Add3DPoly(PointsArray)

'create solid object using regionObj and tempPolyline
 Set SolidObj = ModelSpace.AddExtrudedSolidAlongPath(regionObj(0), tempPolyline)

'delete LWPolyObj
 LWPolyObj(0).Delete
'delete regionObj
 regionObj(0).Delete
'delete tempPolyLine
 tempPolyline.Delete
'now zoom all
 ZoomAll
End Sub

RE: AddExtrudedSolidAlongPath Automation Control from VB

Both work.
Dim tempPolyline As Acad3DPolyline 'your code
Dim tempPolyline As Object 'my code

Object or entity - often even variant.
In VBA, when Object, no curser hint to methods and properties. When Acad3DPoly etc., upon typiong the dot, pop up menu shows relevant properties etc.
The trick was that addGroup returns an array - I would never have expected this.

Glad it was useful.

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