29
November

Finally! Side Entrance Done!

by Scoutn on 29. November 2009 14:20,
under Categories: General

It took a few months but our side entrance is finally done! Well, apart from cosmetic clean up. It was a serious pain, but at least it’s done and we saved a ton of cash doing it ourselves.

I can’t thank Nancy’s brother enough. Without him, I would have had a wet basement all winter for sure. Love ya brother! Seth and Rob too; they did grunt work and helped me with the concrete. And of course Nancy; she helped and put up with my constant frustration.

I messed up with the base foundation of the concrete, but I’ll fix that in the spring. I’ve had enough for now.

Anyway, on to some pictures.

What we inherited:

IMG00215-20090612-0703

Part way through:

PA070490

IMG_2673

Finished!

IMG_2773 

IMG_2768

Comments (2) Tags: more... Post RSS E-mail del.icio.us
26
November

EPDM API: Rename Files Using a Serial Number

by Scoutn on 26. November 2009 17:01,
under Categories: EPDM

In our organisation, we’re going to start renaming our files to a new part number when a part no longer fits the “form, fit, or function” rule. Meaning, when a part is not interchangeable with the last revision, we don’t up-rev, we create a new part number.  Helps with costing and all that jazz.

Since we use serial numbers to generate our part numbers and we don’t allow duplicate file names, we run into a problem. We could have tried ‘save as’, generate a serial number, note the number and use that, but the returned serial number would be reused on the next save. We could also try to maintain our part numbers outside of EPDM, but we’d be missing a feature already built in and would in all likelihood run into duplicate part numbers.

So, I built an add-in to handle this for us. The add-in renames all selected files with the next serial number. The serial number generator is currently hard-coded, so you’ll want to change that if you use the code. (I can’t do everything for you!)

So, does it work? I was worried about file references so I decided to do a quick test. Here is a simple assembly before the rename:

EPDMContains1

And after:

EPDMContains2

Are the file references updated? Let’s check:

EPDMContains3

All is well.

Download here: EPDMRename.zip (148.01 kb)

Comments (0) Tags: more... Post RSS E-mail del.icio.us
11
November

Lest We Forget

by Scoutn on 11. November 2009 12:09,
under Categories: General

As is my personal tradition, I went to Streetsville for the Remembrance Day ceremonies. I have been going every year since I was 13 years old and I have noticed the diminishing ranks of veterans. It’s humbling.

This year there was a special moment when the father and sister of Marc Diab placed a wreath at the cenotaph: the crowd began to clap. It wasn’t expected and it was touching. It was awesome to see so many people pay tribute and understand what sacrifice was made. (Marc Diab was a soldier from Mississauga that was recently killed in Afghanistan.)

To those that have served and are serving: Thank You.

IMG_2763

IMG_2764

IMG_2765

Comments (1) Tags: more... Post RSS E-mail del.icio.us
06
November

EPDM: IEdmEnumeratorVariable vs IEdmBatchUpdate2

by Scoutn on 6. November 2009 15:14,
under Categories: EPDM

I mentioned in my last post that I would update the code for the SetHyperlinkVariable
add-in to use BatchUpdate instead of iterating over each file. I figured I would do a little testing and see which is actually more efficient.

I tested using both IEdmEnumeratorVariable8 and IEdmBatchUpdate2 on 20 files. IEdmBatchUpdate2 out-performed IEdmEnumeratorVariable8 each time, sometimes as much as 2:1. I assume the main reason is because of the SQL behind the scenes; BatchUpdate does just what it says, it updates the SQL in one batch whereas the Enumerator does each file.

But there is a catch

IEdmBatchUpdate2 will not update a variable unless it is part of a data card. If the variable you wish to update is not part of a data card, it won’t update the database. This could cause issues if you don’t have a data card for each file type you’re adding. Something to remember.

The changed code is available here: EPDMSetHyperlinkVariable.zip (232.66 kb)

Comments (0) Tags: more... Post RSS E-mail del.icio.us
02
November

EDPM: Creating an EPDM Add-in

by Scoutn on 2. November 2009 18:50,
under Categories: EPDM

SolidWorks Enterprise PDM (EPDM) ships with an extensive API that provides one with various methods and properties to interact with a vault. With a little knowledge and vision there isn’t much that can’t be done as far as customising your installation.

Most API examples start off with a “Hello World” example, but I am going to do something a little different and provide a working add-in that may prove useful. The add-in sets a variable called “FileHyperlink” to the ‘explore ‘ link. There are other commands one can use for the link, but explore is best suited here.

There are two methods that must be implemented when creating an add-in because your add-in implements the IEdmAddin5 interface. The first being GetAddInInfo() and the second being OnCmd().

GetAddInInfo(): EPDM Calls this method when the add-in is loaded. This is where you’ll set the add-in information as well as add any hooks or commands that you wish EPDM to call. (Commands are for menu or tool bar commands. Hooks are for events.) Take note that the AddInVersion is an integer value, so values of 1.1 or 2.3 are not supported.

public void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 vault, IEdmCmdMgr5 cmdMgr)
{
    poInfo.mbsAddInName = "EPDMSetHyperLinkVariable";
    poInfo.mbsCompany = "Your Company";
    poInfo.mbsDescription = "Sets a file variable called FileHyperlink to the explore link.";
    poInfo.mlAddInVersion = 1;
    poInfo.mlRequiredVersionMajor = 7;
    poInfo.mlRequiredVersionMinor = 0;

    cmdMgr.AddHook(EdmCmdType.EdmCmd_PreUnlock, null);
    cmdMgr.AddHook(EdmCmdType.EdmCmd_PreUndoLock, null);
}

OnCmd(): EPDM calls this method whenever one of your commands or hooks you registered in the GetAddInInfo method is executed. The data array is an array of EdmCmdData structs, which contains information about the files or folders passed to the callback.

public void OnCmd(ref EdmCmd edmCmd, ref Array data)
{
    if (data == null)
        return;

    if (edmCmd.meCmdType == EdmCmdType.EdmCmd_PreUnlock || edmCmd.meCmdType == EdmCmdType.EdmCmd_PreUndoLock)
    {
        IEdmVault8 vault = (IEdmVault8)edmCmd.mpoVault;
        foreach (EdmCmdData cmdData in data)
        {
            IEdmFile5 file = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, cmdData.mlObjectID1);
            IEdmFolder5 folder = (IEdmFolder5)vault.GetObject(EdmObjectType.EdmObject_Folder, cmdData.mlObjectID2);

            object hyperlink = String.Format(conisioString, vault.Name, folder.ID.ToString(), file.ID.ToString(), file.Name);
            
            if (file != null && folder != null)
            {
                if (file.IsLocked)
                {
                    IEdmEnumeratorVariable8 EnumVar = (IEdmEnumeratorVariable8)file.GetEnumeratorVariable(file.GetLocalPath(folder.ID));
                    if (EnumVar != null)
                    {
                        try
                        {
                            EnumVar.SetVar("FileHyperlink", String.Empty, ref hyperlink, false);
                        }
                        catch (Exception ex)
                        {
                            System.Windows.Forms.MessageBox.Show(String.Format("An error occured setting hyperlink variable: {0}.", ex.Message), "Set hyperlink variable", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                        }
                        finally
                        {
                            EnumVar.CloseFile(true);
                        }
                    }
                }
            }
        }
    }
}

There are a couple of lines in the code above that are not required but I generally include them because they are in my Visual Studio template, and it saves me having to remember to do these checks.

First I check if the array of files is null, and if it is, I don’t do anything. This is redundant because the add-in isn’t calling a command; it’s hooked into an event which will always have data associated with it.

The other is the first if statement; I check to see if the command type (event) is the one we want. Again, this is redundant because we added the hooks for this event and we’re running the same code for both events. If we were executing different code for each event we would need to check which event is being called.

IEdmEnumeratorVariable8

The IEdmEnumeratorVariable8 interface is used to update file and folder variables. Generally the interface is used to update single files and using IEdmBatchUpdate is more efficient. (I’ll follow up with a post updating this code to use batch update.) I wanted to make a point on CloseFile().

Always call CloseFile() in a try… catch… finally block. The IEdmEnumeratorVariable interfaces ‘open’ the file when creating the type. If you don’t close the file when you’re done with it, you could (and probably will) run into problems.

Summing it up

I realise this isn’t much of a tutorial, but there isn’t a lot to teach here. The only requirement when creating an add-in for EPDM is that you reference the latest version of EdmLib, and you implement the IEdmAddin5 interface correctly.

I’ll do my best to provide examples of the new features of the EPDM 2010 API but in the meantime if you have any suggestions of specific areas of the API you’d like me to post on, feel free to leave a comment.

You can find the source code for this add-in and others on the EPDM page.

Comments (5) Tags: more... Post RSS E-mail del.icio.us