diff --git a/Script Examples/CreateSearchSets_Timeliner.py b/Script Examples/CreateSearchSets_Timeliner.py new file mode 100644 index 0000000..a4cb0cd --- /dev/null +++ b/Script Examples/CreateSearchSets_Timeliner.py @@ -0,0 +1,54 @@ +import datetime +# build period names from start to end +# set the periods from the beginning of the job to the end of the job +SearchFolderName = 'OPD_TimeLiner' +yr_beg = 2023 +wk_beg = 51 +yr_end = 2025 +wk_end = 9 +listof = [] +for y in range(yr_beg, yr_end + 1): + if yr_beg == yr_end: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(wk_beg, wk_end + 1)] + elif y == yr_end: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(1, wk_end + 1)] + elif y == yr_beg: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(wk_beg, 53 + 1)] + else: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(1, 53 + 1)] + listof.append(wlist) + +#confirm SearchFolderName doesn't already exist, rename _old +for ss in doc.SelectionSets.RootItem.Children: + if ss.DisplayName == SearchFolderName and ss.IsGroup: + doc.SelectionSets.EditDisplayName(ss, SearchFolderName + "_old") + # perhaps the old one should just be deleted + +#create new "timeliner" folder at the end of the existing search sets +nextIndex = doc.SelectionSets.RootItem.Children.Count +savedFolder = FolderItem() +savedFolder.DisplayName = SearchFolderName + +for y in listof: + yr = y[0] + yearFolder = FolderItem() + yearFolder.DisplayName = str(yr) + for wk in y[1:]: + # create another folder group for each year + s = Search() + # sc = SearchCondition.HasPropertyByDisplayName('OPD_LineList','SCHEDULED INSTALL') + # ABOVE IS CORRECT, BELOW IS FOR TESTING AND PROOF OF CONCEPT + sc = SearchCondition.HasPropertyByDisplayName('OPD_Schedule','SCHEDULED INSTALL') + oData = VariantData.FromDisplayString(wk) + sc = sc.EqualValue(oData) + s.SearchConditions.Add(sc) + s.Selection.SelectAll() + s.Locations = SearchLocations.DescendantsAndSelf + savedSet = SelectionSet(s) + savedSet.DisplayName = wk + yearFolder.Children.Add(savedSet) + savedFolder.Children.Add(yearFolder) + +doc.SelectionSets.InsertCopy(nextIndex, savedFolder) + + diff --git a/Script Examples/CreateTimeLiner_Timeliner.py b/Script Examples/CreateTimeLiner_Timeliner.py new file mode 100644 index 0000000..478fc80 --- /dev/null +++ b/Script Examples/CreateTimeLiner_Timeliner.py @@ -0,0 +1,33 @@ +from datetime import datetime +from datetime import timedelta + +# build period names from start to end +# set the periods from the beginning of the job to the end of the job +yr_beg = 2023 +wk_beg = 51 +yr_end = 2025 +wk_end = 9 +listof = [] +for y in range(yr_beg, yr_end + 1): + if yr_beg == yr_end: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(wk_beg, wk_end + 1)] + elif y == yr_end: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(1, wk_end + 1)] + elif y == yr_beg: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(wk_beg, 53 + 1)] + else: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(1, 53 + 1)] + listof.append(wlist) + + +#create time timeler entries to match up with search sets and link +#need to identify week beginning and ending dates for planned start/end +# dtStart = datetime.datetime.strptime("") +for y in listof: + yr = y[0] + for wk in y[1:]: + d = wk + # d = "2024.1" + dtStart = datetime.strptime(d + '-1', "%Y.%W-%w") + timedelta(days=-1) + dtEnd = dtStart + timedelta(days=6) + print(dtEnd) \ No newline at end of file diff --git a/Script Examples/CreateViewPoint_per_Area.py b/Script Examples/CreateViewPoint_per_Area.py new file mode 100644 index 0000000..3bf4188 --- /dev/null +++ b/Script Examples/CreateViewPoint_per_Area.py @@ -0,0 +1,43 @@ +# Search +# first build a collection of objects that have an area. +# in order to get a list of all the areas available +# search doesn't work for custom categories, must iterate +areas = dict() +allItems = doc.Models.RootItemDescendantsAndSelf +for item in allItems: + prop = item.PropertyCategories.FindPropertyByDisplayName('OPD_LineList','Area') + if prop: + areaName = prop.Value.ToDisplayString() + if areaName not in areas.keys(): + mic = ModelItemCollection() + mic.Add(item) + areas[areaName] = mic + else: + mic = areas[areaName] + mic.Add(item) + areas[areaName] = mic + +for area, mic in areas.items(): + # remove existing viewpoint if exists + vps = doc.SavedViewpoints.RootItem.Children + for svp in vps: + vpName = svp.DisplayName.ToString() + if (vpName == area): + doc.SavedViewpoints.Remove(svp) + # set all of model transparency + # might be worth seeing if the viewpoint can just be edited for items visibility instead of editing the model + doc.Models.OverrideTemporaryTransparency(doc.Models.RootItemDescendants,50) + # set for current area to no transparency + doc.Models.OverrideTemporaryTransparency(mic,0) + bbc = mic.BoundingBox().Center + nvp = Viewpoint() + nvp.Position = bbc + vt = Vector3D(0,1,0) + nvp.AlignDirection(vt) + nvp.RenderStyle.Shaded + nvp.HeightField = 0.872657 + svp = SavedViewpoint(nvp) + svp.DisplayName = area + print svp.DisplayName + doc.SavedViewpoints.AddCopy(svp) + diff --git a/Script Examples/CreateViewPoint_per_NWC.py b/Script Examples/CreateViewPoint_per_NWC.py new file mode 100644 index 0000000..b862078 --- /dev/null +++ b/Script Examples/CreateViewPoint_per_NWC.py @@ -0,0 +1,39 @@ +# Search +s = Search() +s.Selection.SelectAll() +# variant needed for equals Value +# oData = VariantData.FromDisplayString('Rooms') +sc1 = SearchCondition.HasPropertyByDisplayName("Item","Name") +# oSearchCondition = oSearchCondition.EqualValue(oData) +sc1 = sc1.DisplayStringContains('.nwc') +s.SearchConditions.Add(sc1) +a = s.FindAll(doc,False) + +# Create Collection and fill it with the items found +modelItems = ModelItemCollection() +a.CopyTo(modelItems) + +# Loop through collection of found items +for item in modelItems: + # Get some properties to build the view name later + # This would change for OPD use case + #number = item.PropertyCategories.FindPropertyByDisplayName('Element', 'Number') + #strnumb = number.Value.ToDisplayString() + name = item.PropertyCategories.FindPropertyByDisplayName ('Item', 'Name') + strname = name.Value.ToDisplayString() + # This next pert is locating the camera, so if we're focusing on an item, + # then OPD will again need to tweak this section to put the camera + # in the correct location and orientation + bbc = item.BoundingBox().Center + nvp = Viewpoint() + nvp.Position = bbc + vt = Vector3D(0,1,0) + nvp.AlignDirection(vt) + nvp.RenderStyle.Shaded + nvp.HeightField = 0.872657 + # Save the settings to a view + svp = SavedViewpoint(nvp) + #svp.DisplayName = strnumb + " " + strname + svp.DisplayName = strname + print svp.DisplayName + doc.SavedViewpoints.AddCopy(svp) \ No newline at end of file diff --git a/Script Examples/PrintBaseFiles(from NWD).py b/Script Examples/PrintBaseFiles(from NWD).py new file mode 100644 index 0000000..81e948f --- /dev/null +++ b/Script Examples/PrintBaseFiles(from NWD).py @@ -0,0 +1,2 @@ +for model in doc.Models.First.RootItem.Children: + print(model.DisplayName) \ No newline at end of file diff --git a/Script Examples/PrintBaseFiles(from NWF).py b/Script Examples/PrintBaseFiles(from NWF).py new file mode 100644 index 0000000..88d11e0 --- /dev/null +++ b/Script Examples/PrintBaseFiles(from NWF).py @@ -0,0 +1,2 @@ +for model in doc.Models: + print(model.FileName) \ No newline at end of file diff --git a/Script Examples/PrintBaseSourceFileName(from NWD).py b/Script Examples/PrintBaseSourceFileName(from NWD).py new file mode 100644 index 0000000..d0ed8c1 --- /dev/null +++ b/Script Examples/PrintBaseSourceFileName(from NWD).py @@ -0,0 +1,5 @@ +for model in doc.Models.First.RootItem.Children: + prop = model.PropertyCategories.FindPropertyByDisplayName("Item","Source File Name") + sourcefile_long = prop.Value.ToString() + sourceFileName = sourcefile_long.Replace("DisplayString:", "") + print(sourceFileName) \ No newline at end of file