Find specific property in drawing sheet format and change the content
Find specific property in drawing sheet format and change the content
Hi everyone. My question is as follow :
There is a linking property named $PRP:"SW-File Name" in EVERY drawing sheet format. Is it possible to get it and change the content to certain words or to custom property like $PRPSHEET:"Customer Spec" via VBA? Any idea is welcomed.
There is a linking property named $PRP:"SW-File Name" in EVERY drawing sheet format. Is it possible to get it and change the content to certain words or to custom property like $PRPSHEET:"Customer Spec" via VBA? Any idea is welcomed.
Like @josh said, this is possible. Below are some links for reference
https://help.solidworks.com/2023/Englis ... ple_VB.htm
https://www.codestack.net/solidworks-ap ... nd-delete/
https://r1132100503382-eu1-3dswym.3dexp ... QxyGwzG7Ew
Go to full posthttps://help.solidworks.com/2023/Englis ... ple_VB.htm
https://www.codestack.net/solidworks-ap ... nd-delete/
https://r1132100503382-eu1-3dswym.3dexp ... QxyGwzG7Ew
Re: Find specified property in drawing sheet format and change the content
Not one reply!? It's a little bit frustrated... Maybe I didn't express my problem clearly.
This work can be accomplished by batch replacing sheet formats. But I cannot do it because there are some properties in the drawings linked to specific view name. Further more, there are some drawings contain more than 2 pages.
Once again, any help is appreciated~
This work can be accomplished by batch replacing sheet formats. But I cannot do it because there are some properties in the drawings linked to specific view name. Further more, there are some drawings contain more than 2 pages.
Once again, any help is appreciated~
Re: Find specified property in drawing sheet format and change the content
OK... You have asked if it is possible... Yes, it's possible.
Are you actually asking someone to do it for you?
Are you actually asking someone to do it for you?
- AlexLachance
- Posts: 1994
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2157
- x 1847
Re: Find specified property in drawing sheet format and change the content
It's not very clear to me what you are trying to achieve, so that could be a reason why people are hesitant to answer.
Why would you want a manual entry rather then use the existing ones? Do you understand the entries and what they link?
Why would you want a manual entry rather then use the existing ones? Do you understand the entries and what they link?
Re: Find specified property in drawing sheet format and change the content
I believe he's looking for a "Find-Replace" in annotations, except that it works for notes linked to properties rather than just looking at the displayed text.
- DanPihlaja
- Posts: 747
- Joined: Thu Mar 11, 2021 9:33 am
- Location: Traverse City, MI
- x 738
- x 893
Re: Find specified property in drawing sheet format and change the content
Artemis' #TASK would do this, I think. I don't think that it works any more though.
-Dan Pihlaja
Solidworks 2022 SP4
2 Corinthians 13:14
Solidworks 2022 SP4
2 Corinthians 13:14
Re: Find specified property in drawing sheet format and change the content
Hello Alex. Please forgive my bad English. I've been using SW for more than 10 years, so yes, I know the entries and what they link.
Actually, what I want is to replace "$PRP:"SW-Folder Name"" with "$PRPSHEET:"Customer Spec"" in the sheet format, not the "File Name" I mentioned before.
Older drawings show the full path name in the customer specification field, which is the link "$PRP:"SW-Folder Name"", but the displayed text is too long. Now I create a new template, use simple code to extract the spec information I need, and write it into the custom property, which is the link "$PRPSHEET:"Customer Spec"".
The new template works well and has been running for a while, but I have to go back and work on the old projects.
There are so many drawings to process, but they are just repetitive actions. I know this job can be done using VBA code batch processing, but I'm still very new to programming, so came here to ask for help.
Actually, what I want is to replace "$PRP:"SW-Folder Name"" with "$PRPSHEET:"Customer Spec"" in the sheet format, not the "File Name" I mentioned before.
Older drawings show the full path name in the customer specification field, which is the link "$PRP:"SW-Folder Name"", but the displayed text is too long. Now I create a new template, use simple code to extract the spec information I need, and write it into the custom property, which is the link "$PRPSHEET:"Customer Spec"".
The new template works well and has been running for a while, but I have to go back and work on the old projects.
There are so many drawings to process, but they are just repetitive actions. I know this job can be done using VBA code batch processing, but I'm still very new to programming, so came here to ask for help.
Re: Find specified property in drawing sheet format and change the content
Hi, Josh, thanks for the reply, but I'm not here to ask someone to do it for me.
In fact, I did some research. I used the information on the Internet and my very shallow knowledge of VBA to write some code, but I always failed. That's why I'm here for help. What I need to replace is the link in the sheet format rather than the drawing, but the following code always shows that it cannot be defined. I am still working on it.
Re: Find specified property in drawing sheet format and change the content
Like @josh said, this is possible. Below are some links for reference
https://help.solidworks.com/2023/Englis ... ple_VB.htm
https://www.codestack.net/solidworks-ap ... nd-delete/
https://r1132100503382-eu1-3dswym.3dexp ... QxyGwzG7Ew
https://help.solidworks.com/2023/Englis ... ple_VB.htm
https://www.codestack.net/solidworks-ap ... nd-delete/
https://r1132100503382-eu1-3dswym.3dexp ... QxyGwzG7Ew
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger
Re: Find specified property in drawing sheet format and change the content
Hi, Deepak. Thank you for the three links you provided, I will read them carefully later. I believe I can get helpful information from them.gupta9665 wrote: ↑Tue Nov 07, 2023 3:21 am Like @josh said, this is possible. Below are some links for reference
https://help.solidworks.com/2023/Englis ... ple_VB.htm
https://www.codestack.net/solidworks-ap ... nd-delete/
https://r1132100503382-eu1-3dswym.3dexp ... QxyGwzG7Ew
Re: Find specified property in drawing sheet format and change the content
@gupta9665
I modify the code you provided in the 3rd link, and it works perfect!
I've always thought that the code for replacing properties in a sheet was different than the code for replacing properties in a sheet format.
Thank you again~ Here is the code
==============================================================================================
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swNote As SldWorks.Note
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swView = swDraw.GetFirstView
While Not swView Is Nothing
Set swNote = swView.GetFirstNote
While Not swNote Is Nothing
If swNote.PropertyLinkedText Like "$PRP:""SW-Folder Name(Folder Name)""" Then
Debug.Print "Replacing " & swNote.GetText & " (" & swNote.PropertyLinkedText & ")"
swNote.PropertyLinkedText = "$PRPSHEET:""Customer Spec"""
End If
Set swNote = swNote.GetNext
Wend
Set swView = swView.GetNextView
Wend
End Sub
I modify the code you provided in the 3rd link, and it works perfect!
I've always thought that the code for replacing properties in a sheet was different than the code for replacing properties in a sheet format.
Thank you again~ Here is the code
==============================================================================================
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swNote As SldWorks.Note
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swView = swDraw.GetFirstView
While Not swView Is Nothing
Set swNote = swView.GetFirstNote
While Not swNote Is Nothing
If swNote.PropertyLinkedText Like "$PRP:""SW-Folder Name(Folder Name)""" Then
Debug.Print "Replacing " & swNote.GetText & " (" & swNote.PropertyLinkedText & ")"
swNote.PropertyLinkedText = "$PRPSHEET:""Customer Spec"""
End If
Set swNote = swNote.GetNext
Wend
Set swView = swView.GetNextView
Wend
End Sub