API - search for custom properties

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply John 10/12/2003 9:13:08 PM

See related articles to this posting

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
Reply 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
Reply 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
Reply 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
Reply 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
Reply Brenda 10/13/2003 3:49:38 PM
comp.cad.solidworks 14541 articles. 55 followers. Post

5 Replies
235 Views

Similar Articles

[PageSpeed] 13

  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

API
Could someone share a few pointers on how to go about creating an API (using VB) to manipulate (and create) custom properties for part models and assembly models. I have programming experience so a reference to the specific methods and properties of the part object model would suffice. I have a bunch of part models to which I wish to add a few custom properties and values to those properties. I hope to be able to open each model make the changes and close the model. While I'm at it, is it possible to open a bunch of drawings and refresh the sheet layout programatically? Foraging...

API: Delete all custom properties
I have found several examples of how to do this but none seem to work, I need a macro that I can run that will delete all custom properties regardless of property name. I have a macro that will add custom properties and it is written so that it does not require solidworks, it uses windows to create the custom property. I would like to do the same for deleting the custom properties. Can someone please provide some sample code showing how to delete all custom properties? Thanks, Sam This function works inside a SolidWorks VBA Macro : '** 'Delete all file of configuration properties...

SolidWorks API
Does anyone know how to get the evaluated value from a custom propert to show in a text box instead of the linked solidworks' dimension pat after an engineer links the dimension to the property (a practice lot of us are doing at my work) I have a field in a userform that shows the length of a part, but when my user links that custom property to an actual dimension in th model, he will then see the solidworks pathway to that dimension i the user form text box, when, it would be much more useful to sho him what the value is (instead of the pathway)... like 6" fo example I have a sing...

API to Print Drawing with a Current Date and Time placed into a custom property
Dear SolidWorks guys, Looking for a macro that will print a drawing and take the current time and date and place it in a custom property that can be plced in the title block. This is not the available inside SolidWorks just the created date and last saved date. The general VB command you want to use is the Now function. It returns the date and time, so you can use it just after you callout the print command. Dim dtmnow as Date dtmnow = Now Please provide any input or macros if possible? Daniel This was discussed earlier check this link http://groups.google.com/groups?hl=en&lr=&...

API: Need help to add custom property to Structural Members (SLDLFP-files)
Hey I have been trying to make a macro, so I can change the properties on all my weldment profiles. I have putted together some pieces but I cant find any info on how to treat the SLDLFP files, its no problem with the standards (drawings, parts and assemblies). So here is what I got so far.. I have putted some stars where I need input :-) Dim swApp As SldWorks.SldWorks Dim swModel As ***** Dim ReturnVal As Long Dim Response As String Dim DocName As String Dim Success As Boolean Dim DocType As String Dim swUpper As String Dim swDocTypeLong As Long Dim nErrors As Long Dim nWarnings As Long C...

custom-custom properties list
In installing 2007, I first used the copy settings wizard, and backed up my templates/sheet formats. I removed 2006 including the registry references, then installed 2007. I used the wizard to restore my settings. All settings seem to be as they were, except my custom properties list. I had to manually re-enter the 10 or so custom properties that we've accumulated. As the list of non-standard custom properties seems to grow with time, I'd like to know, for future upgrading, where that data was stored in the first place, so that I can simply copy it over. Its not part ...

Get custom scale as a custom property
Hi, Is there a way to get a view's scale as a custom property? I know you can get the sheet scale but my view's scales are set as different custom scales. My sheet scale is always 1:1. Is it a good way to work? What I understand of the scaling system is that the sheet format environment is always 1:1. When you set the scale as custom scale, the scale is apply in reference to the sheet format. When you scale with "sheet scale", you make the sheet bigger/smaller over the model (part, asembly) wich stays 1:1. Is it right?... but anyway I want the custom property of a view set to...

make a custom property equal a solidworks property
Is it possible to get a property that someone creates read a SolidWorks property? For example, can $PRP:"SHTNO" be made to equal $PRP:"SW-Current Sheet" ??? Just enter the desired string into the property. Should work. It might need a rebuild to update though. If you enter $PRP:"SW-Current Sheet" into a custom prop SHTNO it will do what you are asking. Corey <goatlip@hotmail.com> wrote in message news:1107356986.068114.132390@z14g2000cwz.googlegroups.com... > Is it possible to get a property that someone creates read a SolidWorks > property? &g...

Weird custom properties in my custom sheet format
I have my company's title block & sheet set up as a custom sheet format, which I insert via "Add Sheet." The title block contains text which is linked to custom properties. All work perfectly except for two: Project and Engineer. Those two seem to be set up exactly as all others are, but when I insert my custom sheet, instead of getting the value of those fields (example 1234A and John Doe) I get the custom property name in quotes ("Project" and "Engineer"). Also, those two are black, where the rest of the text is blue. I can fix this by editing the s...

Custom Control, How to add properties to properties window?
Hi, I'm developing a custom control based on the Canvas class. How can I add my own properties so they appear in the properties window? For example I'd like to pass in some extra colours. Thanks in advance, Jules. Oooops.... I found it... But what about Defaults ? Thanks... Jules. In article <428e0f07$0$295$cc9e4d1f@news-text.dial.pipex.com>, "JZ" <jj@anon.anon.com> wrote: > Oooops.... I found it... > But what about Defaults ? You can't change the default values. Best, - Joe ,-----------------------...