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 14461 articles. 56 followers. Post

5 Replies
344 Views

Similar Articles

[PageSpeed] 35


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

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

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

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

Custom Property Rename
I need some major help. Has anyone ever heard of a macro/program that will read a custom property that I specify off of a Solidworks 2005 part, then rename that file to the custom property value. And be able to do this in some kind of batch mode, not just individual files. If no one can help me, I am going to have a huge amount of work in front of me. I know you guys can do it. Rescue me! lol There is no rename for custom properties. Any macro would have to add one and delete the other. If none of the properties are config-specific, it can all be done without opening files. Is this ...

custom properties 230228
Using VB is there a way of accessing custom properties of a selected 'object' in an assembly rather than having to open this part/ assembly and then using 'ActiveDocument' type access? cheers nigel Dim CompDocument as SldWorks.ModelDoc2 Dim Component As SldWorks.Component2 ........... set CompDocument = Component.GetModelDoc This should get you started Corey "Bates, Nigel" <nigel.bates@sira.co.uk> wrote in message news:7226CB02D0CB0D489C08C1AACAB446E4074D6A@EPICURUS... > Using VB is there a way of accessing custom properties of a selected > 'obje...

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

Custom Properties have disapeared!
Custom Properties have disapeared from a slew of files! Any ideas as to what would cause this? TIA On Jun 13, 2:47 pm, cox.ge...@gmail.com wrote: > Custom Properties have disapeared from a slew of files! Any ideas as > to what would cause this? > > TIA Maybe a macro was intentional designed and executed to batch erase properties, or the misuse/accidental use of macro with that capability? Matt http://sw.fcsuper.com cox.geoff@gmail.com wrote in news:1181771258.844310.294980 @d30g2000prg.googlegroups.com: > Custom Properties have disapeared from a slew of files! Any ide...

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

HOW TO CAPTURE CUSTOM PROPERTIES?
I'm in the process of trying to document our CAD standards. Being a sheetmetal job shop we have created part templates based on material type, thickness, bend radius and k-factor. I need to document these settings, I started by right-clicking on the template file and selecting properties and then the custom tab. Looking at these properties I then manually type them into an excel spreadsheet. I finished the aluminum materials (14 different templates) and I thought to myself, "there must be a easier way to do this." Does anyone know of a program that could capture this informa...

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