Perforce version control functions in Maxscript

Perforce version control functions in Maxscript

ClaudioAlvaro
Contributor Contributor
2,130 Views
14 Replies
Message 1 of 15

Perforce version control functions in Maxscript

ClaudioAlvaro
Contributor
Contributor
Hi,

I'm running into a snag when I attempt to determine if a file is under version control. I'm using hiddenDosCommand with P4 command lines and redirecting output to a temp file which I then read. This works for a few files, but when I need to go through a slew of them, the disk writing can get extremely slow. Does anyone have any experience or suggestions to avoid having to write to disk?

I've installed the graphical tool plug-in from P4, but as far as I can tell, nothing is exposed to maxscript.

Any hints or help would be greatly appreciated.

CL Audio
3dsMax 2009 sp1 32-bit ( +creativity extension )
---
3DSMax 2012 SP2
0 Likes
2,131 Views
14 Replies
Replies (14)
Message 2 of 15

gplourde
Participant
Participant
I wrote a maxscript extension using the p4 api. It was fairly simple and virtually gave me access to every p4 command with output in maxscript string. Unfortunately I cannot share that with you but if you know a bit of the 3dsmax sdk, it should take few hours.
0 Likes
Message 3 of 15

Anonymous
Not applicable
I used <a href="http://p4dotnet.sourceforge.net/index.php/P4.Net_Overview">P4.NET</a>; with that assembly, it was fairly easy to do everything else from MAXScript.
0 Likes
Message 4 of 15

ClaudioAlvaro
Contributor
Contributor
Thanks for the info. I'll check out P4.Net.
---
3DSMax 2012 SP2
0 Likes
Message 5 of 15

ClaudioAlvaro
Contributor
Contributor
I can get as far as generating a connection with p4Net, and I think I'm connecting to the perforce depot, but I only get errors with anything I try to do. I have really little dotNet experience which doesn't help...

Any help or sample code would help here.

&#40;Once I get to the office I'll post what I've got so far&#41;.
---
3DSMax 2012 SP2
0 Likes
Message 6 of 15

Anonymous
Not applicable
Hello,
I have recently encountered recent issues while in the process of fin tuning our pipeline. and the information in this thread has been instrumental. The key to the dotnet p4 usage is in the "run" command where most p4 commands can be called as well as passed information. The help file that comes with the p4.net assembly is quite useful.

As I get deeper into the p4 docs I am finding cleaner and more efficient ways of implementing various functionality in the scripts. While I have found a good number of solutions that work fairly well. I would be interested in seeing some script snippets for different ideas and ways of using these function in script.

While I can not post the bulk of what I am doing I will try to put together some general examples on here that could help others as well as feed the ideas exchanges.
0 Likes
Message 7 of 15

ClaudioAlvaro
Contributor
Contributor
I gave up entirely on this due to lack of time. Here's what I have and where it burps. I'm probably setting this up wrong, any help would be helpful.

dotnet.loadAssembly "C:\\dotNet\\P4.Net\\bin\\CLR_1.1\\p4api.dll"
p4 = dotNetObject "p4api.p4Connection"
p4.connect&#40;&#41;


And here's the reported error

-- Runtime error: dotNet runtime exception: Could not load file or assembly 'p4dn, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.


When I attempt loading the p4dn.dll file through the dotnet.loadAssembly method I get the following

-- Error occurred in anonymous codeblock; filename: C:\p4dotNet.ms; position: 145; line: 2
-- Runtime error: dotNet runtime exception: Invalid directory on URL.


I have no clue what I'm doing here so any help would be appreciated.

Testing in 2009 32bit and 2010 64bit.

CL Audio
---
3DSMax 2012 SP2
0 Likes
Message 8 of 15

ClaudioAlvaro
Contributor
Contributor
Turns out p4.net doesn't work in 64bit.
---
3DSMax 2012 SP2
0 Likes
Message 9 of 15

alecf
Enthusiast
Enthusiast
This depends on whether you're using P4V or P4Win. When we had P4Win, I was able to simply connect to p4 using this: DOSCommand &#40;"p4 edit \""+anim+"\""&#41;

Supposedly, p4v comes with a commandline version, also called p4, but damned if I can open it. I need to keep trying, though. If I get it to work with p4v, I'll let you know.

Alec
0 Likes
Message 10 of 15

ClaudioAlvaro
Contributor
Contributor
What we currently do is redirect the output of the p4 command to a text file, and then parse it. This is fine if you need to simply check out a file or a diff, but if you need to compare local files to those on a depot &#40;in the hundreds&#41;, parsing a text file is not the best approach.

P4.Net uses data forms to parse output. Unfortunately we're moving to 64bit windows and 3dsMax 2010, so that eliminates p4.Net as a potential solution.
---
3DSMax 2012 SP2
0 Likes
Message 11 of 15

Anonymous
Not applicable
There is one more site that is good and I also have visited it,this has provided me such information that is really unique and the service that they offer also I have experienced, really I enjoy this service so I want to make an appeal to others please visit this and I want to tell you that after experiencing this service mcse questions you’ll enjoy it again and again.
0 Likes
Message 12 of 15

alecf
Enthusiast
Enthusiast
OK, got it working again via P4 command line. If you go here:
http://perforce.com/perforce/downloads/index.html

You can download Perforce Command-Line Client, which will allow you to call the full complement of perforce commands. Make sure when it's setting up that you disable the install of the perforce server, which is on by default. Just install the Command-Line Client. Then, from the DOS prompt, you can check to make sure your environment variables are set properly by typing "p4 set". That will list any of the known perforce environment variables that are already set. Mine didn't have the P4CLIENT environment variable set up, so it ended up choosing the wrong workspace. P4CLIENT defines the workspace, so if you need to set that up, just type &#40;no brackets&#41; and you should be good to go.
Once installed, you can call any of the commands on this page using MaxScripts DOSCommand:
http://perforce.com/perforce/doc.current/manuals/cmdref/index.html

Hope that helps. Let me know if you have any setup questions and I'll try to help.

Alec
0 Likes
Message 13 of 15

Anonymous
Not applicable
One warning with command line, especially when doing batch operations. You will want to include a few fail-safes in your scripts. To check if the commanded action was actually carried out. In some cases, I found that sending the command two consecutive times solved many problems. In other cases I simply checked if the giving command had been cared out. If that check comes up false then send the command again.

One example:
• Max script tells p4 to check a file out. NOTE: Read only flag should be set to false
• Then have max script check the read only flag in the file. It it is still true, there is a good chance the check out command failed. Then send the command line again.

Another way to confirm success is printing the command line output to a text file then read in the text file. I keep this in reserve for specific operations where I really need the information. This option is slow from a run-time efficiency stand point.

A nice way to hide this from the end user is the hidden dos command.

For debugging purposes, both mind and the end users. I tend to print activity logs to the listener.
0 Likes
Message 14 of 15

Anonymous
Not applicable
Supposedly, p4v comes with a commandline version, also called p4, but damned if I can open it. I need to keep trying, though. If I get it to work with p4v, I'll let you know.


The P4v installer has a habit of moving the p4.exe command-line file and failing to update the system path to match. The fix is to just run the P4v installer a second time.
0 Likes
Message 15 of 15

lalamax3d
Explorer
Explorer

For debugging purposes, both mind and the end users. I tend to print activity logs to the listener.


can you please share a simple example of how to get console output to listener?
in my case, i am attempting to connect my max with svn. svn client works fine from cmd prompt. all i wanted currently is to get output to listener.

another problem in my mind is, how exactly to know, hidden dos command has finished.
my psudo solution is like
1- start timer before hidden dos command and create empty log file. see its time stamp
2- check timer after few steps and see, file modification and read log from there etc

is this ideal way.??thanks in advance for time to read and sharing knowledge..
0 Likes