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 14463 articles. 55 followers. Post

5 Replies
319 Views

Similar Articles

[PageSpeed] 49


  • 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 ,-----------------------...

Copy a custom prop value to another custom property?
For whatever reason, where I work decided to use a different custom property other than Description to fill in their descriptions for parts and assemblies, and the use this to fill in the drawing title block, making that custom, and the BOM, making the BOM template custom as well. The main reason I feel we need this changed is because it adds a level of complexity to creating toolbox fasteners that I think is unnecessary. This situation requires that toolbox fastener descriptions also need to be customized, adding another ambiguous custom property, so the fastener's description will read...

Custom properties
I'm using the Preferences class and have some objects to represent with Strings for storage.I have for example a rectangle class that may have a string representation "0,0,50,100".Now saving a property is not a problem I just have a CustomProperty interface and call toPropertyString().But loading a property is a case of documenting that CustomProperty classes must provide a no arg public contstructor, and then I can call CustomProperty.fromPropertyString(myPropStr) to populate the object.Now I'd really like to have immutable properties, and I realise I can have a toImmutableI...

Adding custom list and text boxes to the custom tool bar from Excel C API
Hi All, I am developing an addin excel using Excel C API. I want to know is there any way to add custom list and text boxes to the custom tool bar from Excel C API? If yes how can we do it? Any help would be greatly appreciated. Thanks, Mousam Dubey ...

API: 2nd posting please help! [was API: Eeeek! "Ghost" on edges of generated drawing w/properties]
Hello everyone, I am creating a utility which generates formatted drawing sheets from a user form. The problem I am having is that when the form appears on the screen, the image does not seem to fill the whole window pane. The left and top edges have a kind of "ghost" on them. If anyone wants to help I will be glad to send a screen (scream?) shot. There is about a 1/4" margin on the top and left hand sides that acts as if the drawing is not filling it. If I "ALT/TAB" to another window, then back, when I go back the margins contain left over image from the previous ...

BUTTON FOR CUSTOM PROPERTIES
With the interface change in 2008 it is a bit of a PITA to get to the file - custom properties. I've been looking for a button that I can add to the main toolbar, is there one available or will I have to create a macro? TIA Wormsign On Dec 10, 8:07 am, "WormSign" <worms...@doon.com> wrote: > With the interface change in 2008 it is a bit of a PITA to get to the file - > custom properties. I've been looking for a button that I can add to the > main toolbar, is there one available or will I have to create a macro? > > TIA > Wormsign Haven't ...

Setting custom properties
I know that I can read/write custom properties of an object by using the following: Setting: document.all['Control'].customProp = "this"; Getting: document.all['Control'].customProp; Is there a way I can run code when this custom property is set. Or perhaps there is a way to create a custom method? Example: <span id="MySpan"><input type="text"></span> I'd the property: document.all['MySpan'].enabled = true; To automatically do this: document.all['MySpan'].controls[0].disabled = !thevalue; OR the ...

Custom properties 74000
Hello, I'm an engineer and my core occupation is designing new machines. I have got a new project from my bosses and I need to re-organize the stock of drawings. My question is the next: How can i add custom properties like "mass" and "material" into each part and how do i add those custom properties in PDMWorks without selecting them each time. Thanks for your help. Steven Vandermeulen Spiessens NV PS: does anyone have some tutorials concerning PDMWorks and custom properties for me. I would be quite usefull for me I think. Spiessensnv@gmail.com wrote: > He...

custom properties in assy
Can anyone tell me how to use some of the custom properties from one of the components in an assembly drawing? thanks, Jim jacito@gtweed.com Dear Jim, I'm not sure about but u can try this : Inser that component first into the sheet and link all the custom properties you want to link with that component. Place that component outside the sheet. Now bring in your assy and other details. Regards Deepak ...

Delete Custom Properties
I am looking for a macro that will recursively search a directory, find every SolidWorks file, and delete all of the custom properties in each file. Can anyone give me a macro that does that, or at least point me in a direction where I can find what I need. Thanks On Aug 22, 12:47 pm, inthepickle <inthepic...@gmail.com> wrote: > I am looking for a macro that will recursively search a directory, > find every SolidWorks file, and delete all of the custom properties in > each file. Can anyone give me a macro that does that, or at least > point me in a direction where I can ...

Operators in Custom properties
I want to include some data in my drawing template to show things like the area of the part. SW-Surface area doesn't work for me because I just need the 2D area contained on say, a 4' x 8' sheet of UHMWPE. I've realized I'll probably have to manually enter a value for this area, but I then want to take that entered value and multiply it by a certain factor like 1.25. Ideally, the designer would enter in the area of the part and the notes on the drawing would automatically fill themselves in like so... Area: 32 square inches Material Required: 40 square inches Is there...

custom properties blank
i've been meaning to ask this for quite some time. i'd like to adjust my macros so that they don't create a blank space holder. so the question is, how does pdmw create custom properties without any blank spaces? --- kb All you have to do is call the AddCustomInfo2 command, but pass in a "" value. "kenneth b" <massielabs@hotmail.com> wrote in message news:2uslk1F2d8o0fU1@uni-berlin.de... > i've been meaning to ask this for quite some time. > > i'd like to adjust my macros so that they don't create a blank space holder. > so the...

Custom properties from ODBC
Anybody tried pulling custom properties from ODBS or SQL Server using SW macro I think this is little bit over my head, but I'm willing to learn Looking for some tutorials, code examples or anything to get me started Hi We offer a SolidWorks add-on that can do that "out-of-the-box". Take a look at ToolWorks ERP-Link Download a trial from http://www.toolworks.info Jess "mr.T" <mr.T@Somewhere Far away from the rainbow.com> wrote in message news:6aAkg.24756$VE1.9729@newssvr14.news.prodigy.com... > Anybody tried pulling custom properties from ODB...

Custom Properties 356480
Hello All, I'm completely self taught in SW and have never had the occasion to use custom properties. Are there any books on the subject or that cover the subject. Or could someone give me a very basic do this, this, and this, I would be grateful. What I'm looking for is a way to set up some custom properties in my drawings, like material for one. TIA, Muggs On 2004-08-14, Muggs <Muggs828@home.net> wrote: > Hello All, > > I'm completely self taught in SW and have never had the occasion to use > custom properties. > Are there any books on the subject or tha...

Is there a associative custom property that....
Is there a associative custom property that lets me know the where a part is used in what assemblies? This property needs to be in the specific part so that on the sheet format that contains the part, it will show me the next level up the part is contained in? something like $PRPSHEET:"Description" except it will tell me what assemblies the part is in... Hope that made sense. Ben It makes sense and probably could be done in conjunction with a PDM system. The basic problem is that parts, as lower level documents, don't know or carry knowledge about the entities that refere...

custom properties not sticking...
A client of mine (I do some SW contract work) just sent me this email: "I enter the parameters in the xxx config for my end panel. Go to the drawing and the format fields update. I save the part & drawing and close them out. I reopen the drawing and the format fields are now empty. I open the part and the parameters I entered are also gone. I have reentered the parameters 3 times and they keep disappearing. Can you please tell me why, oh why does this keep happening. I must know the answer and the solution." I don't have the files available to look at right now...