Connecting PHP to PDMWorks

Anyone tried to connect PHP to PDMWorks?

Any snippets to do the job will be highly appreciated.

Thanks in advance.SolidworksApi macros
Answers 9
SF
SF 2009-03-17 Best Answer
PDMWorks API is on windows, PHP runs on unix.... problem.

What exactly are you trying to achieve?
SF
SF 2009-03-17
PHP will run onWindows.

See thePHP COMclass.

My guess would be that you would need to instantiate a PDM COMobject, something along the lines of:

$conn = new COM("PDMWorks.PDMWConnection");
$conn->Login("pdmwadmin", "pdmwadmin", "localhost");
{do stuff}
$conn = null;
SF
SF 2009-03-19
@Luke
thanks. i'm already running both PHP and PDMWorks on windows. and iwould like to access PDMWorks API with PHP so it can interoperatewith our current web-app. what we are trying to achieve is to getthe BOM of assembly drawings in the vault and use it in ourweb-app.

@Lee
thanks, i'm looking at PHP COM and was able to make the connectionyesterday... though we're still working on how to get the BOM.
SF
SF 2009-03-24
A struct is like a class.

Have you tried passing an array to the method?

$objArray = array();
$vfileobj = $vobj->GetObjects($objArray);


After the method call you should have an array filled withEdmObjectInfo objects. You can then iterate over the array or justaccess it directly;

$objectInfo = $objArray[0];
$objID = $objectInfo->moObjectID;


It's been years since I have used PHP so this will probably needsome tweaking, but hopefully it helps in some way.
SF
SF 2009-03-26
@ lee
thanks.
yes, i've tried passing an array() but i'm getting a "Caughtexception: Parameter 0: Type mismatch. "...
i really need to make this work.. else i won't be able to get thebom interfaces. (sigh)







SF
SF 2009-03-26
I'm grasping at straws on this one but try:

$objArray = array();
$v = new VARIANT( $objArray, VT_ARRAY );
$vfileobj = $vobj->GetObjects($v);

SF
SF 2009-03-27

Lee Young wrote:

 

I'm grasping at straws on this one but try:



$objArray = array();

$v = new VARIANT( $objArray, VT_ARRAY );

$vfileobj = $vobj->GetObjects($v);

i tried the above codes but still got the same error: "Caughtexception: Parameter 0: Type mismatch. "


(hoping to give us more clue) i've also tried to add this line inmy PHP script...com_print_typeinfo($vobj);linkto PHP doc

and got the following result for the GetObjects() function:


/* DISPID=33 */
functionGetObjects(
/* VT_PTR [26] [in][out] --> VT_SAFEARRAY [27] */&$ppoObjects
)
{
/* method GetObjects */
}
SF
SF 2009-03-27
I've tried getting this to work but I have been unsuccessful.In fact, calling GetVersion() returns a type mismatch error, and Iam not able to login to the vault. Are you running PHP underFastCGI or ISAPI? (Now I remember why I gave up on PHP...)
SF
SF 2009-04-07
Sorry for the late reply, been busy with other programs thepast couple of days.

Regarding your question, i'm running PHP as ISAPI. On theotherhand, you said you're getting a type mismatch error callingGetVersion(), I think you need to declare the $major and $minorvariables before you can use them as parameters for theGetVersion() function.

I hope you continue to help me work through this problem.