Run-time error '13' Type mismatch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anyone find where this mismatch error is occurring I have been trying to fix it but have not been successful.
Ive attached a picture of the code also showing the error.
Thank you to anyone who can help
Public Sub hex()
'activate the part as a document
Dim pdoc As PartDocument
Set pdoc = ThisApplication.ActiveDocument
Dim pdef As PartComponentDefinition
Set pdef = pdoc.ComponentDefinition
'Establish input dimensions
Dim dim1, dim2
dim1 = InputBox("Enter Hex Size", "HEX")
dim2 = InputBox("Enter Hex Length", "Length")
Dim sides As Long
sides = 6
'create new reference sketch plane
Dim sketch As PlanarSketch
Set sketch = pdef.Sketches.Add(pdef.WorkPlanes.Item(3))
'Sets reference to tg transient geometry
Dim tg As TransientGeometry
Set tg = ThisApplication.TransientGeometry
'Create lines for polygon
Dim hex As SketchLine
Set hex = sketch.SketchLines.AddAsPolygon(sides, tg.CreatePoint2d(0, 0), tg.CreatePoint2d(0, dim1), False)
'Creates a profile.
Dim Pfile As Profile
Set Pfile = sketch.Profiles.AddForSolid
'Create an extrusion.
Dim extrudeDef As ExtrudeDefinition
Set extrudeDef = pdoc.Features.ExtrudeFeatures.CreateExtrudeDefinition(Pfile, kJoinOperation)
Call extrudeDef.SetDistanceExtent(dim2, kNegativeExtentDirection)
Dim extrude As ExtrudeFeature
Set extrude = pdoc.Features.ExtrudeFeatures.Add(extrudeDef)
End Sub