How to show current part file name and description in the text box.?
1. You can set the textbox.text value to IModelDoc2::GetTitle method to show the file name.
2. Description depends on where do you want the description value to be read. Is it a custom property or something else?
Could you attach your macro?
Sorry for the late reply,
Here with I've added the code which you suggested for the File name
Private Sub NFN_Change()
Dim instance As IModelDoc2
Dim value As String
value = instance.GetTitle()
NFN.Text = value
Unfortunately file name is not displayed in the textbox, could you help me ?
Yes, its from Custom property.
Sorry,I'dnt have macro to attach. its from scratch we are trying.
Its never going to change due to you using the textbox change event to set the textbox text. If you want it to bring in the information when the form loads then change the Sub name to UserForm_Activate, where UserForm is the name of the userform.
To get the custom property you will need to use a bit of code like this:
textbox.text = instance.Extension.CustomPropertyManager("configurationname").Get("Description") where "configurationname" is the name of the configuration and "Description" is the custom property you would like to retrieve.
Matt Bieringer has already given you some idea. I would like to add few more comments.
1. I cannot see you have assigned 'instance' (IModelDoc2 object) to an active document in SolidWorks (I believe you are running the userform after you have opened a document in SolidWorks).
2. You only need to specify the configuration name, if you want to get configuration specific property. If you want to get document level custom property, then you need to specify an empty string instead of configuration name.
3. 'ICustomPropertyManager::Get' is an obsolete method, use 'ICustomPropertyManager::Get5' method.
Again Sorry for the late reply,
Thanks for your effort and support Nilesh Patel and Matt Bieringer
I'll try and let you know soon. Since I'm in travel.
Retrieving data ...