12
March

EPDM API: Data Helper Class

by Scoutn on 12. March 2010 16:53,
under Categories: EPDM

Since I have trouble remembering what the members are of the EdmCmdData structs I wrote a helper class. Instead of mlObjectID1, mlObjectID2, etc, I am presented with the corresponding data for the struct.

So instead of:

foreach (EdmCmdData cmdData in data)
{
    int fileId = cmdData.mlObjectID1;
    int parentFolderId = cmdData.mlObjectID3;
    IEdmFile5 file = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, fileId);
}

I’m using this:

                EPDM.Utils.DataHelper helper = new EPDM.Utils.DataHelper();
                List<EPDM.Utils.EdmCmdMenu> files = helper.GetInfo<EPDM.Utils.EdmCmdMenu>(data, edmCmd);
                foreach (EPDM.Utils.EdmCmdMenu file in files)
                {                    
                    IEdmFile5 file = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, file.FileID);
                }

I know it doesn’t look like much. Until you get to something that uses a large stuct;

snap

Enjoy.

EPDM.Utils.DataHelper.zip (204.30 kb)

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

Hi, My Name is Lee

by Scoutn on 4. March 2010 12:42,
under

And I am Canadian. I’d like to introduce you to a country where every voice, no matter how quiet or loud is heard. We take every complaint seriously. The customer (meaning you) is always right. We’re here to serve your needs and we never, ever, think of our own. We’ll roll over and show our bellies for anyone who barks.

(Unless of course it’s the majority. Here in Canada that is. If you’re a foreign majority, we’ll gladly roll over and show our deep fear of offending anyone.)

Case in point: A woman decides she not comfortable singing “In all thy son’s command” in our national anthem. (That would be the Canadian National Anthem for those of you that forgot what country you’re in.) So our government decides that it may need to be discussed, and maybe we should switch back to the original wording of “in thou dost us command”.

Here’s my take on it: GO FOR IT! Change it back to the 1909 lyric!

While you’re at it though:

  • Bring back the Lords prayer in the schools.
  • Christmas Trees
  • National Anthem in the morning too
  • Naps after recess (Working class)

Thank you for ruining the pride I felt. You had to bring political correctness into the only thing connecting Canadians during a period of recovery.

The ONLY connection I have to the east or west coast is the national anthem.

Comments (0) more... Post RSS E-mail del.icio.us
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 (0) 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 (2) Tags: more... Post RSS E-mail del.icio.us
14
October

Bravest Raccoon in Oakville

by Scoutn on 14. October 2009 18:28,
under Categories: General | WTF

I don’t know what this little guy is thinking, but he is lucky I am in a good mood, and that I really don’t feel like going to the vet tonight…

IMG_2678

If this was the country he wouldn’t stand a chance.

IMG_2677

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

Welcome to Home Ownership – Part 2

by Scoutn on 11. October 2009 10:39,
under Categories: General

There is a side entrance of my house that is incomplete. Meaning, there is a door, but not much else besides a hole in the ground. This is what I inherited:

IMG00215-20090612-0703

They dug down enough to put the door in, but left it at that. They also left a big pile of dirt, stone, and screening on the other side of the house for me to deal with. Since the city knew about the door, I had to go through the building permit process and get a permit and approval to finish the job.

Normally I wouldn’t have been able to keep the door because the houses are so close but because they are linked underground, the house is considered a semi-detached. So, all is well and good. (Unless you ask my neighbor,  they hate the fact I am keeping the door. They wanted me to brick up the door.)

So I have just completed digging enough for the footings. Four feet down from the landing under the door. Eight days later and seven trips to the dump, I’m finally done this stage. Hopefully the inspector is fine with what I have done.

IMG_2674

One thing I have learned so far; it is not easy trying to do this by yourself. Working with red clay is not fun. Next time, I’ll ask for help.

The digging is done and I am glad!

PA070494

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

Taking Twitter too far

by Scoutn on 28. September 2009 13:15,
under Categories: General | WTF

A story was recently posted on Slashdot about a credit union in the U.S. that allows one to interact with their financial accounts via Twitter, including checking account balances and transfer funds.

With apologies to Bad Idea Designs

What are they thinking? It is possible that this is secure using SSL and direct messages, but how many people out there know how to use SSL? What happens when someone mistypes what they want to do in Twitter and they set their current tweet to something that contains financial information? Would you want the whole world knowing that you have X amount of dollars to transfer?

I do not see the reasoning behind this at all. Where is the convenience?

So how is this mobile? If your phone can send and receive text messages and you’re on Twitter, you’re in! tweetMyMoney uses Twitter’s Direct Message feature to return the account information you request.

Don’t they have telephone or online banking? Why add the extra layer?

I just don’t get it. What’s next, a Facebook online banking app?

Wow.

Comments (0) more... Post RSS E-mail del.icio.us