×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

API for the Dumb Guy

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

RE: API for the Dumb Guy

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

RE: API for the Dumb Guy

(OP)
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

RE: API for the Dumb Guy

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

RE: API for the Dumb Guy

(OP)
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?

RE: API for the Dumb Guy

(OP)
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

RE: API for the Dumb Guy

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

RE: API for the Dumb Guy

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

RE: API for the Dumb Guy

(OP)
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

RE: API for the Dumb Guy

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources