API - search for custom properties

Discussion in 'SolidWorks' started by John, Oct 12, 2003.

  1. John

    John Guest

    I have made a routine in VBA:

    Public Function CustPropFound(CustProp As Variant, model As ModelDoc2) As
    Boolean
    Dim numCustProps As Long
    Dim Names As Variant

    Names = model.GetCustomInfoNames2("")
    numConfigs = model.GetCustomInfoCount2("")
    i = 0
    CustPropFound = False
    While i < numConfigs And Not CustPropFound
    If model.CustomInfo2("", Names(i)) = CustProp Then
    CustPropFound = True
    End If
    i = i + 1
    Wend
    End Function

    But somehow it can't detect when the Names(i) = CustProp. When looking at
    the variables they look the same...

    Is another way of comparing required?

    John
     
    John, Oct 12, 2003
    #1
  2. Bob Hanson Wrote:

    Perhaps make the CustProp a string not a variant...

    Best Regards,


    --
    Bob Hanson
    CEO
    Custom Programming Unlimited LLC
    SolidWorks Solution Partner for SW API training/consulting and SW PDM
    provider
    www.cpuandsimplepdm.com website
    (Home of SW API Public Code snippets)

    SW World User Conference Exhibitor Booth #407
     
    Robert Hanson, Oct 13, 2003
    #2
  3. John

    John Guest

    .... I already did that (which I should have said...) and it doesn't work
    either. So what then?
     
    John, Oct 13, 2003
    #3
  4. John

    Heikki Leivo Guest

    ... I already did that (which I should have said...) and it doesn't work
    What are you actually trying to achieve? In the code above you seem to be
    comparing custom property value (model.CustomInfo2()) with variable
    CustProp... If I understood right, you should have If Names(i) = CustProp
    instead.

    -h-
     
    Heikki Leivo, Oct 13, 2003
    #4
  5. John

    John Guest

    Yep... just found that myself. Embarrassing....

     
    John, Oct 13, 2003
    #5
  6. One further note...
    You may want to ensure that your comparison is case-insensitive by doing a
    UCase on both sides:
    If ucase(Names(i)) = ucase(CustProp)

    Regards,
    Brenda
     
    Brenda D. Bosley, Oct 13, 2003
    #6
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.