bart
March 5, 2015, 9:27am
1
Hello
I'm looking for a way to recover my room's location properties
Example: My document is saved in a "Case X" folder, in a "Client Y" folder
I would like the name of the client file and the name of the case to appear on my block.
Docn I want to retrieve the registration path and only show the name of the client and the case, because often I forget to indicate it and I realize it once the printing is finished.
Lucas had directed me to a macro.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.AddCustomInfo2 "File Path", swCustomInfoText, Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "\"))
End Sub
The macro doesn't have any errors, but I'm not sure how to do it afterwards.
So that this information ends up on my cartridge.
For your information, I go through a personal property form.
Thank you! =)
pl
March 5, 2015, 9:33am
2
Hi, actually the macro should add a custom property called "File Path" that you can then use in your title block or in an annotation.
1 Like
bart
March 5, 2015, 9:37am
3
Why does the personal property "File path" give me the name of the client file and the name of the business file?
How to divide them? I would have liked to have had the name of the client in one box, and of the case in another.
It's possible?
bart
March 5, 2015, 9:40am
4
Well I did a test on an annotation.
I end up with the full path as if I had put the folder name property.
pl
March 5, 2015, 9:42am
5
Can you put an example of a path by specifying the name of the client and the deal?
1 Like
bart
March 5, 2015, 10:02am
6
Here is the screenshot
I would like to put "Client X" in the client box and "Affaire Y" in the construction site or Ref box.
macro.png
pl
March 5, 2015, 10:33am
7
Then you have to add the following part before the End Sub:
filepath = Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "\")) end = Len(filepath) - 1 pos_cli = InStrRev(filepath, "\", end) client = Mid(filepath, pos_cli + 1, end - pos_cli) pos_aff = InStrRev(filepath, "\", pos_cli - 1) case = Mid(filepath, pos_aff + 1, pos_cli - 1 - pos_aff)
swModel.AddCustomInfo2 "Client", swCustomInfoText, client
swModel.AddCustomInfo2 "Deal", swCustomInfoText case
1 Like
pl
March 5, 2015, 10:33am
8
There's probably a simpler solution, but at least it works!
The macro will add 2 more custom properties that you can use in your title block:
"Client" for the client's name
"Deal" for the deal number
1 Like
bart
March 5, 2015, 10:39am
9
As long as it works, I'm fine with it!
it seems like a macro to me, but I have an error on the client= Mid line (FilePath, po_cli+1, end-pos_cli)
pl
March 5, 2015, 10:42am
10
Indeed you have a mistake because you didn't copy and paste well!
It 's _cli and not po_cli
1 Like
bart
March 5, 2015, 10:43am
12
No, I just retyped badly on Lynkoa
I put correctly: client = Mid(FilePath, pos_cli + 1, end - pos_cli)
macros.png
pl
March 5, 2015, 10:53am
13
Strange, what is the error?
1 Like
bart
March 5, 2015, 10:56am
14
Runtime Error 5
Invalid argument or procedure call
bart
March 5, 2015, 2:19pm
15
Are you drying Lucas? :p ^^
1 Like
pl
March 5, 2015, 3:16pm
16
Sorry I didn't have time to test it more deeply, I'm looking at it tonight.
1 Like
bart
March 5, 2015, 3:36pm
17
No worries Lucas, it's nice of you!
I do this as a common thread, so it's not extremely urgent;)
In any case, your macro looks very good. You manage!
I really need to train myself on this....
Have a good end of the day!
1 Like
pl
March 5, 2015, 5:17pm
18
Sorry I don't understand, at home it works!
I'll put you in PJ the file that works at home so that you can test...
Thank you for the compliments and have a good end of the day to you too.
path.swp
bart
March 6, 2015, 3:06pm
19
I don't understand either...
At home or at the office, always the same mistake.
I'm under 2014.
A little photo novel? if you have the time of course!
pl
March 6, 2015, 5:02pm
20
Do you know how to use debugging for macros? Otherwise I can take control of your computer remotely?