API for the Dumb Guy
API for the Dumb Guy
(OP)
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
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






RE: API for the Dumb Guy
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
RE: API for the Dumb Guy
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
RE: API for the Dumb Guy
Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...
RE: API for the Dumb Guy
RE: API for the Dumb Guy
Chris
Sr. Mechanical Designer, CAD
SolidWorks 05 SP2.0 / PDMWorks 05
ctopher's home site
FAQ371-376
FAQ559-1100
FAQ559-1091
FAQ559-716
RE: API for the Dumb Guy
Now, I want to use VBA to look at THAT TEXT and get the value.
Does that make sense?
Brian
RE: API for the Dumb Guy
I have not used VBA to do this.
Chris
Sr. Mechanical Designer, CAD
SolidWorks 05 SP2.0 / PDMWorks 05
ctopher's home site
FAQ371-376
FAQ559-1100
FAQ559-1091
FAQ559-716
RE: API for the Dumb Guy
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
RE: API for the Dumb Guy
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
RE: API for the Dumb Guy
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
RE: API for the Dumb Guy
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