View Full Version : Sample Code to reach the Template Path
Patrick_Aps
07-14-2010, 07:30 AM
Hi,
does anyone have a piece of sample code that reads out the options to find the path where the drawing templates are located ?
Patrick, this will get you to the reference data.
Sub getRootPath(path As String)
Dim tempPath As Integer
Dim datasource As LMADataSource
Set datasource = New LMADataSource
Dim objFilter As LMAFilter
Dim criterion As LMACriterion
Set criterion = New LMACriterion
Set objFilter = New LMAFilter
criterion.SourceAttributeName = "Name"
criterion.ValueAttribute = "Rules Library"
criterion.Operator = "="
objFilter.ItemType = "OptionSetting"
objFilter.Criteria.Add criterion
Dim objOptionSettings As LMOptionSettings
Dim objOptionSetting As LMOptionSetting
Set objOptionSettings = New LMOptionSettings
'get "Default Assembly Path" from OptionSettings by filter
objOptionSettings.Collect datasource, Filter:=objFilter
Set objOptionSetting = objOptionSettings.Nth(1)
'Debug.Print "Name = " & objOptionSetting.Attributes("Name").value
path = objOptionSetting.Attributes("Value").value
tempPath = Len(path) - 9
path = VBA.Left(path, tempPath)
Set datasource = Nothing
Set objFilter = Nothing
Set criterion = Nothing
Set objOptionSettings = Nothing
Set objOptionSetting = Nothing
End Sub
You can tag the path to the template files after the line "path = VBA.Left(path, tempPath)" with something like
path = VBA.Left(path, tempPath)
path = path & "\Whereareyourtemplates\"
I am pretty buried at the moment but if that doesn't work for you I can adjust it. I just had this code handy.
You can directly get template path by modifying dave's code.
criterion.ValueAttribute = "Rules Library"
to be
criterion.ValueAttribute = "PID Template Path"
Patrick_Aps
07-14-2010, 10:25 PM
Thanks guys,
Where else do we find such good "overnight" support.
I posted this question just before going home yesterday,
and the answers are here as I come back in the office today.
np Patrick, that's why we're here!
Tim is right (thanks tim!), but make sure you comment out
tempPath = Len(path) - 9
path = VBA.Left(path, tempPath)
that part ;)
Patrick_Aps
07-16-2010, 11:44 AM
Don't worry, we got it working.
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.