Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API Rumination

Status
Not open for further replies.

gedkins

Mechanical
May 11, 2001
45
Folks,

Somewhat of a philosophical question.

Since Custom Property names are case sensitive regarding capture via VB &
VBA does anyone have a nice clean way of "looking past" the case of a
property to grab the value regardless of how it was defined originally
(example: Cost, cost, COST,etc). var1 =
ModelDoc.GetCustomInfoValue(ConfigName, "COST") would miss the prop Cost.

I have a method I use but feel its somewhat clunky (read slow). The
philosophical part of this is that if one used a software tool to define the
custom props at part creation they would all be uniform case and the problem
is solved, but alas we all know there are always exceptions!

Thoughts.... ruminations?


Guy Edkins
Managing Partner
Delta Group Ltd

gedkins@deltagl.com
 
Replies continue below

Recommended for you

Just one more data validation problem. Seems like most of the effort in programming goes to validation and error control, not to the actual process.

[bat]I may make you feel, but I can't make you think.[bat]
 
well, the props are case insensitive, but only to a degree.
You can have a "material" property, OR a "MaTeRiAl" property, but NOT a "material" AND a "MaTeRiAl" property.

So this is no different than any other text validation:
force the case of the text on both the needed, and the stored property, and see if they are an exact match.
 
Hmmmmm, Am I missing something. In the following call the two fields (description are different)? i.e. the call would miss getting the value if it were description (all lower case) I must have taken a stupid pill this morning as I am sure that the answer is simple.

var1 = ModelDoc.GetCustomInfoValue(ConfigName, "DESCRIPTION")
var1 = ModelDoc.GetCustomInfoValue(ConfigName, "Description")

Guy Edkins
Managing Partner
Delta Group Ltd

gedkins@deltagl.com
 
I tried, and was unable to make 2 props with the same letters but different capitalizations.

I entered a value for "Description", and clicked the "Modify" button to save it.

I then Started typing "DESC", clicked the mouse on the value box, entered a value, and watched the "Modify" button change to an "ADD" button. I then tried tricking it, and mouse-clicked back on the "Name" field, and finished typing in "ription" .. by the time i hit the "n", I watched the "ADD" button change to a "Modify" button.
 
Yes its an interesting problem, when you attampt to create props in SW it won't let you have as you say two props of the same name with different case. But the API call sees the (or doesn't see) Description as different from DESCRIPTION which is the pain.

Guy Edkins
Managing Partner
Delta Group Ltd

gedkins@deltagl.com
 
Look up the following keywords in VB help:

StrConv
LCase
UCase

You could probably write a subroutine to compare string values (i.e. chack to see if values of two stringsare the same when both are forced lowercase)

[bat]I may make you feel, but I can't make you think.[bat]
 
gedkins,

To further expand on TheTick's idea, you could write a routine that loads all of the custom properties and their values into an array, then deletes all the custom properties from the document and finally resaves the custom properties but using the LCase, UCase, etc functions to modify their names to whatever designation you desire.

Regg [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor