Highlight Method in VBA & MD6

Discussion in 'AutoCAD' started by Kevin Saruwatari \(Home\), Dec 18, 2003.

  1. Hi;

    I'm having a little trouble with the highlight method in VBA. In the
    following snippet, I'm selecting a MD part, testing each feature and, if is
    a drilled hole, I'm trying to highlight the edges that a hole is referenced
    from and pop a dialog box with the distance.

    Everything works except the highlight. I get the error "Generic failure to
    execute operation with the provided arguments." I can't find what I'm doing
    wrong in the help files. Any suggestions would be greatly appreciated.


    Sub ParamTest()
    Dim objMcadApp As McadApplication
    Dim objMcadPart As McadPart
    Dim objMcadParam As McadParameter
    Dim objMcadFeat As McadFeature
    Dim objTestDescr As IMcadDescriptor 'McadCounterSinkDescriptor

    Dim colMcadParms As McadParameters
    Dim colMcadFeas As McadFeatures

    Dim util As McadUtility
    Dim pick As McadPick

    Set objMcadApp = Application.GetInterfaceObject("Mcad.Application")

    Set util = objMcadApp.ActiveDocument.Utility
    Set pick = util.pick("Select Component", mcBody)

    Set objMcadPart = util.GetObjectFromPick(pick)
    Set colMcadFeas = objMcadPart.Features

    For Each objMcadFeat In colMcadFeas

    Select Case objMcadFeat.FeatureType

    Case mcDrilledHole
    Set objTestDescr = objMcadFeat.Descriptor(True, True)
    Dim locs As McadLocators
    Set locs = objTestDescr.Locators
    Dim curve As IMcadCurve
    Dim loc As IMcadLocator

    For Each loc In locs
    If TypeOf loc Is McadDistanceLocator Then
    Set curve = loc.Object
    curve.Highlight True, 1
    MsgBox "Distance from edge = " & loc.Distance
    curve.Highlight False, 1
    End If
    Next
    Case...
     
    Kevin Saruwatari \(Home\), Dec 18, 2003
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.