fbpx
  • Free your Drives: Using Relative Paths in your Automated Models

    Here’s the scene: You’re 18 months deep into building automated models and templates for your production team, and everything is working as well as you can hope – but the IT team has an upgrade plan in the works. You and your team of designers are now sporting brand new laptops, better in almost every way from what you were using before, with one small caveat: the hard drives are now a small SSD solely for Operating system usage (C:\) and a large storage drive for everything else (D:\).

    To anyone who is not knee-deep in the automating trenches, this may not seem like a problem at all. You might be thinking, “Well, more space is great!”; but there’s always a ghost in the machine when you’re bootstrapping something like an automated workflow. The main challenge that I’ve seen (and have personally fallen victim to) is that users will hard-code a specific drive into their automated templates when a file path is needed – something that isn’t wrong, but can lead to challenges down the road.

    So, how do we fix it? We’re going to take a look at three options, one of which you may have already considered:

    • Manually Changing the Drive Letter
    • Referencing the Drive Letter via Document Location
    • Referencing the Drive Letter via Project Workspace Location

     

    Manually Changing the Drive Letter

    Let’s start with the simplest, but least robust choice: manually updating the drive letter in your models. Take a look at this snippet of code:

    If Parameter("Location") = "Front"
    Components.Add("FRONT MOUNT CLIP", "C:\BDL_Vault\DeskStorage\Designs\Standard Mounting\133092.ipt")
    Else
    Components.Add("REAR MOUNT CLIP", "C:\BDL_Vault\DeskStorage\Designs\Standard Mounting\133088.ipt")
    End If

    This is a direct reference to a specific folder on my C:\ drive, a distinct location that I’m using to store that specific standard file. Following this concept, you would simply edit each string to look like this:

    If Parameter("Location") = "Front"
    Components.Add("FRONT MOUNT CLIP", "D:\BDL_Vault\DeskStorage\Designs\Standard Mounting\133092.ipt")
    Else
    Components.Add("REAR MOUNT CLIP", "D:\BDL_Vault\DeskStorage\Designs\Standard Mounting\133088.ipt")
    End If

    At this point, your template is updated. The main drawbacks to this method are that the location is still hard-coded (albeit to a new drive letter), and you will need to update each template individually each time this needs to happen.

    Referencing the Drive Letter via Document Location

    When a file is saved, the folder path is stored as a piece of background data that is accessible via iLogic – meaning we can grab this information and pare it down to find the drive the file is stored on. A simple way to access (and display) this information is here:

    Dim DocPath As String
    DocPath = ThisDoc.Path
    MessageBox.Show(DocPath)
    
    

     

    Figure 1: Saved Document Path

     

    After finding the path with the above line of code, we’ll need to find the root of the path, which can be done using the .NET GetPathRoot method:

    Dim RootLetter As String
    RootLetter = System.IO.Path.GetPathRoot(DocPath)
    MessageBox.Show(RootLetter)

     

    Figure 2: Root Drive

     

    Now that we have the drive letter stored in a local variable, we can use that to build out the string we want to use to locate our file, like this:

    Dim StandardLocation As String
    StandardLocation = RootLetter & "BDL_Vault\DeskStorage\Designs\Standard Mounting\"
    MessageBox.Show(StandardLocation)
    Figure 3: New File Location

     

    The main downside to this method is that locating the drive will be entirely dependent on where you’ve saved the file that this rule is going to run in. If you have multiple storage drives and you’ve saved this file on a very specific drive (G:\, for example) then this method will return G:\ as the root drive, which may not be where you mean to look.

     

    Referencing the Drive Letter via Project Workspace Location

    This method is the most variable of the three I’ve mentioned so far, as it relies specifically on where your project file’s Workspace folder is located. The steps to get the drive letter are almost identical to the previous method, but with a slightly different input required. I’ll show you three ways to get the data we want in the snippet below:

    Dim WSPath As String
    WSPath = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
    WSPath = ThisServer.DesignProjectManager.ActiveDesignProject.WorkspacePath
    WSPath = ThisDoc.WorkspacePath
    
    

    The first line of code references the DesignProjectManager object within the context of the Inventor Application. From accessing that object, we can specify that we want to look at the current active project, and then grab the Workspace path from there.

    The second line of code is the same as the first, but rather than referencing the Inventor Application, it references the Inventor Server. Functionally, this will operate the same way when run on the desktop Inventor application, but if you are eventually going to export your models to a cloud-based service (such as SolidCAD’s VARIANT configurator) you will need to reference this Server object instead.

    The final line of code is the simplest, directly referencing the current document, and searching for the Workspace of the currently active project.

    All of the above options will result in a string that looks something like this, when printed inside a message box:

     

    Figure 4: Workspace Path

    After choosing your method (I would recommend #3, personally) you can then take the same steps to get the root of the Workspace and build out your file path:

    Dim RootLetter As String
    RootLetter = System.IO.Path.GetPathRoot(WSPath)
    MessageBox.Show(RootLetter)
    Dim StandardLocation As String
    StandardLocation = RootLetter & "BDL_Vault\DeskStorage\Designs\Standard Mounting\"
    MessageBox.Show(StandardLocation)
    
    

     

    Figure 5: Root Drive and New File Path

     

    This method will ensure that you are always referencing the same drive that your workspace exists on, which is commonly where any automated templates or standard components will be located.

     

    What Does This Actually Look Like?

    Here is an example of a very short conditional rule that makes use of the third method to locate the drive and replace a component based on the triggering parameter:

    Dim WSPath As String
    Dim RootLetter As String
    Dim StandardPath As String
    WSPath = ThisServer.DesignProjectManager.ActiveDesignProject.WorkspacePath
    RootLetter = System.IO.Path.GetPathRoot(WSPath)
    StandardPath = RootLetter & "BDL_Vault\DeskStorage\Designs\Standard Mounting\"
    ThisAssembly.BeginManage("Mounting Clips")
    Select Case Parameter("Location")
    Case "Front"
        Components.Add("FRONT MOUNT CLIP", StandardPath & "133092.ipt")
    Case "Rear"
        Components.Add("REAR MOUNT CLIP", StandardPath & "133088.ipt")
    Case "Left"
        Components.Add("LEFT MOUNT CLIP", StandardPath & "133090.ipt")
    Case "Right"
        Components.Add("RIGHT MOUNT CLIP", StandardPath & "133077.ipt")\
    Case Else
        'No Clip, should never happen
    End Select
    ThisAssembly.EndManage("Mounting Clips")
    InventorVb.DocumentUpdate(True)

    As you can see in context, this doesn’t add very many lines to your overall rule (even less if you initialize the variables with their end values), and it helps to future-proof your code in the case that you will be using different drives over time.

    If you’d like to learn more about iLogic and how to use it, you can continue checking out the articles here on the SolidCHAT blog, or if you’re looking for a more structured or in-depth learning approach, we offer standard and custom training for iLogic and other Autodesk products here at SolidCAD.

    Until next time!

    The Digital Transformation Train is Leaving the Station, and We Should All Be on Board

    2020 has taught me a number of things, including presumably how indoor cats feel, that March and June are the same thing if you don’t go outside, and that if Godzilla were to stumble onto the shores of Tokyo tomorrow,  everyone would probably collectively shrug and go back to getting their coffee. While you’re probably thinking that none of these are very important lessons, I’d point out that a few of them are very strong evidence that today more than ever, is essential for businesses to better use available tools to automate processes, get employees connected, and develop strong digital connections with their customers. I’m not going to tell you which ones. Instead, we’ll jump to the point: the train probably left the station in March, but it’s not too late to get a ticket.

    If you’re not already on board, you’re missing out. Notably, this year has shown a prevalent increase in the “work from anywhere” culture. Covid and WFH are now BFFs, meaning this is a necessity for multiple reasons:  ensuring the safety of your employees, the risk of an outbreak impacting productivity in the workplace, and the added caveat that with the increase in WFH at many businesses means that your employees may see greener pastures elsewhere if you aren’t offering it.

    This doesn’t mean that all digital transformation is created equal. Adopting Microsoft Teams and crossing your fingers is not an effective strategy for adapting to our new reality. Many workplaces have highly involved processes that require generous attention to detail and incredibly effective lines of communication.  So, for a manufacturing business, how do you ensure that this forced digital revolution doesn’t impact your team’s ability to be productive?

    Luckily, the revolution is no longer in its infancy, Covid has only helped it along. Many solutions already exist and for a manufacturer you can easily improve communication and visibility among your teams, automate workflows, and interface with your customer base. Autodesk Vault and Fusion Lifecycle are two such tools that, if not already in your workflow, should be up for consideration immediately.

    What is Vault and Fusion Lifecycle (FLC)? These two products are the rails that the digital transformation train rides on. Fusion Lifecycle is a product lifecycle management tool, and Vault is data management tool. Together, these products rule over your manufacturing data like Facebook does over the data of…well, everyone. With a single source of information, you can control and automate state change and change management tools, ensure a smooth process from project inception to engineering and manufacture easily than ever before.

    The next tool you are most likely missing out on, is a sales tool to bring your CAD data to the fingertips of your sales reps and customers. Let your customers buy their tickets to ride. While some businesses may have leveraged Autodesk Configurator 360 in the past, moving forward, this tool will no longer be supported. This is why, we at SolidCAD, have developed Variant.  Variant is a web based iLogic configurator tool that can be used to easily convert Inventor iLogic assemblies into a powerful sales tool. Suddenly, that model that only engineering teams have seen becomes an interface that your customers can use to make selections, verify their choices, instantly obtain professional quotes, and order your products. If you still have massive catalogues with complex part numbers and PDF order sheets that often result in their own special type of chaos and deficiencies in your sales to manufacturing workflows, your children are probably already making fun of you on TikTok.

    Now, the buck doesn’t just stop here. Its no longer worth it to simply deploy these tools, pat yourself on the back for a job well done, and head home to binge a whole season of the Kardashians on your streaming platform of choice. A train that isn’t well designed likely won’t stay on the tracks for long. Variant, FLC and Vault are all highly customizable and can be fully integrated. A comprehensive digital transformation strategy includes ensuring that these products work perfectly in sync with the bespoke workflows and processes that your business wishes it could achieve, and in a way reduces manual data transfer and intervention wherever possible. Imagine freeing up the bandwidth your sales reps, engineers and production managers expend moving around all this data? Communicating these changes, reducing the possibility for human error and not to mention the likelihood of winning more bids as a direct result of the reduced sales cycle times are just a fraction of the possibilities.

    Not convinced? If your business isn’t already a passenger or ready to buy a ticket, take a moment to consider this: it’s highly improbable that you personally haven’t already benefitted from another business transforming a product, service, or industry. Whether you’ve been streaming Netflix to pass the time, connecting with family over Zoom, or watching your children use the internet to go to school, our lives have never been more touched by digital transformation.  If you have, then there is absolutely no doubt that the same applies to those who work for you or buy from you. In a time where leaving our homes can suddenly have a massive impact on our lives and those of our loved ones, every business needs to consider how they can embrace this era and bring customers and employees closer together while letting them remain well apart.

    All aboard!