Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

API for the Dumb Guy 1

Status
Not open for further replies.

brrian

Mechanical
Jan 21, 2004
164
0
0
US
I don't need to know how to write this... just to know if it's possible.

In my drawing file's title block, there are two notes that are linked to properties that reference the model in the drawing view:

PartNumber
Description:

Can I get the VALUE of each of these notes via VBA? I currently have a VB program that gets these properties by opening the drawing, finding the filename of the referenced part or assembly, opening that file, then recording the custom property's (PartNumber or Description) value.

My thought is that, if I could get those properties via the linked notes in the drawing file, I could speed up the VB program and eliminate some other issues I haven't discussed here.

Can it be done? If yes, I'll try to figure out how to do it. I'm weak w/ VBA and I could spend days trying just to learn that it can't be done.

Thanks,

Brian
 
Replies continue below

Recommended for you

I did not understand well what you are trying to do.

It seems to me that you are creating properties in the drawing and importing them into the part.

If so, you should do the opposite. Create custom proterties in the part. The drawing will automatically import these properties (no VB needed).

Regards
 
I am doing what you've suggested--I have custom properties in a part, which are imported into my title block via notes that are linked to the part's custom properties.

I need to use VB to get to these properties, basically to populate a list that I'll use for a few different functions. I have something that does this now, like this:

For each .slddrw in folder:

-Open .slddrw
-Get file name of part/assembly in views
-Open .sldprt or .sldasm file
-Get custom property "PartNo"
-Get custom property "Description"
-Add to my 'list'
Goto next .slddrw in folder


What I want is something like this:


For each .slddrw in folder:

-Open .slddrw
-Get value of note in title block containing "PartNo"
-Get value of note in title block containing "Description"
-Add to my 'list'
Goto next .slddrw in folder


Does that make sense? In my example, I'm only opening one file to get the desired values. There are other benefits as well that I haven't gone into. With that further explanation, can you tell me if it can be done? Thank you,

Brian
 
If your notes refer to the custom properties, then you don't need to get the value of the notes. Just get the values of the custom properties directly using CustomInfo2.



Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
 
Will CustomInfo2 give me the values from the part or assembly in the drawing views? The fields I want (PartNo and Description) are not saved in the drawing file, they're in the part or assembly. It seems to me (and I could easily be wrong) that CustomInfo2 would give me values from custom properties saved in the drawing file... is that correct?
 
If you have info inserted in "file/properties" of the part/assy files, you can link to those in the text of the dwg title,p/n,etc. without VBA.

Chris
Sr. Mechanical Designer, CAD
SolidWorks 05 SP2.0 / PDMWorks 05
ctopher's home site
FAQ371-376
FAQ559-1100
FAQ559-1091
FAQ559-716
 
Chris--I've done exactly that--linked title block text to custom properties of the part/assy files.

Now, I want to use VBA to look at THAT TEXT and get the value.

Does that make sense?

Brian

 
If you are talking about custom properties or file properties (not configuration dependent properties), you can use DSOfile in your VB.

You must go to M$ site and download the related dll's and instructions.

Using DSOfile you can access the custom properties or file properties silently, without opening the files.

Regards
 
Yes I've done it-And I understand what you are asking.
I use it to Save as drawings by drawing number, partname, and revision automatically. If someone has changed the note to something custom(i.e. severed the link or added text), the filename will accurately reflect what is on paper. However, I don't know if it is faster.

You asked if it is possible: I say yes. For the sake of others reading the thread, I will outline the process:
Find the notes by name, then get the text from that note. There is an example in the API Help.

Some API's I use for this are:
Note.Getname
Note.Gettext

HTH

Kevin

 
Kevin,

Thanks for the reply.

Is it true that you can't get the note name except through the API? I can't find anywhere in SolidWorks that shows the name of the note(s) in my drawings. How did you find your names?

Brian
 
Brian,

Now that that you mention it, I had trouble finding the names too. It's not like dimensions-where you just have to goto properties. I ended up recording a macro as I selected the note. Then I edited the macro to find the name. I got:

boolstatus = Part.Extension.SelectByID2 ("DetailItem100@Sheet Format1", "NOTE", 0.3725183633059, 0.02318850279941, 0, False, 0, Nothing, 0)

"DetailItem100" would be the name I use in my IF THEN statement:

If (note.GetName = "DetailItem100") Then
dwgname = note.GetText
End If

Thanks for the star!

HTH

Kevin
 
Status
Not open for further replies.
Back
Top