API - search for custom properties

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


0
John
10/12/2003 9:13:08 PM
comp.cad.solidworks 14446 articles. 2 followers. Post Follow

5 Replies
509 Views

Similar Articles

[PageSpeed] 15

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


"John" <john@swnewsnomail.com> wrote in message
news:3f89c3e4$0$27402$edfadb0f@dread16.news.tele.dk...
> 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
>
>


0
Robert
10/12/2003 11:36:51 PM
.... I already did that (which I should have said...) and it doesn't work
either. So what then?

"Robert Hanson" <roberth@cpuandsimplepdm.com> wrote in message
news:nAlib.174163$0v4.13371309@bgtnsc04-news.ops.worldnet.att.net...
> 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
>
>
> "John" <john@swnewsnomail.com> wrote in message
> news:3f89c3e4$0$27402$edfadb0f@dread16.news.tele.dk...
> > 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
> >
> >
>
>


0
John
10/13/2003 9:39:49 AM
> ... I already did that (which I should have said...) and it doesn't work
> either. So what then?

> > >         If model.CustomInfo2("", Names(i)) = CustProp Then

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-


0
Heikki
10/13/2003 9:45:25 AM
Yep... just found that myself. Embarrassing....

"Heikki Leivo" <heikki.leivo@SPAM.SUCKS.cadworks.fi> wrote in message
news:Rvuib.53$l76.4@reader1.news.jippii.net...
> > ... I already did that (which I should have said...) and it doesn't work
> > either. So what then?
>
> > > >         If model.CustomInfo2("", Names(i)) = CustProp Then
>
> 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-
>
>


0
John
10/13/2003 10:20:36 AM
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
CustomSolids

"John" <john@swnewsnomail.com> wrote in message
news:U%uib.55$gW3.44@news.get2net.dk...
> Yep... just found that myself. Embarrassing....
>
> "Heikki Leivo" <heikki.leivo@SPAM.SUCKS.cadworks.fi> wrote in message
> news:Rvuib.53$l76.4@reader1.news.jippii.net...
> > > ... I already did that (which I should have said...) and it doesn't
work
> > > either. So what then?
> >
> > > > >         If model.CustomInfo2("", Names(i)) = CustProp Then
> >
> > 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-
> >
> >
>
>


0
Brenda
10/13/2003 3:49:38 PM
Reply: