Skip to content

Instantly share code, notes, and snippets.

@giobel
Last active December 10, 2023 06:32
Show Gist options
  • Save giobel/13f38dfc40565a4911ff501e76f53abd to your computer and use it in GitHub Desktop.
Save giobel/13f38dfc40565a4911ff501e76f53abd to your computer and use it in GitHub Desktop.
## Python and C# Code for Rhino ##
from rhino3dm import *
def move(input):
vectH = Vector3d(2,0,0)
vectV = Vector3d(0,1,0)
xform = Transform.Translation(vectH)
yform = Transform.Translation(vectV)
b = input.Transform(xform)
c = b.Transform(yform)
print (b)
print(c)
return b,c
a = Point3d(0,0,0)
print(f'start {a}')
i = 0
while i<4:
print (i)
result = move(a)
i+=1
a = result[1]
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.Geometry as rg
import Rhino
import math
#2015, Konrad Sobon, archi-lab package
def groupCurves(Brep_List):
ignore_distance = 0.1 # Assume points this close or closer to each other are touching
Grouped_Lines = []
Queue = set()
while Brep_List:
Shape = []
Queue.add(Brep_List.pop()) # Move a line from the Brep_List to our queue
while Queue:
Current_Brep = Queue.pop()
Current_Brep_Pts = GetExtrusionEndPoints(Current_Brep)
Shape.append(Current_Brep)
for Potential_Match in Brep_List:
#Points = (Potential_Match.PointAtStart, Potential_Match.PointAtEnd)
Points = GetExtrusionEndPoints(Potential_Match)
for P1 in Points:
#for P2 in (Current_Brep.PointAtStart, Current_Brep.PointAtEnd):
for P2 in (Current_Brep_Pts):
distance = rs.Distance(P1,P2)
if distance <= ignore_distance:
Queue.add(Potential_Match)
Brep_List = [item for item in Brep_List if item not in Queue]
Grouped_Lines.append(Shape)
return Grouped_Lines
def GetExtrusionEndPoints(objId):
obj = rs.coercegeometry(objId)
objType = str(obj.GetType())
Points = ()
if objType == "Rhino.Geometry.Brep":
line = find_average_line_between_vertices(objId)
Points = (line.PointAt(0), line.PointAt(1))
elif objType == "Rhino.Geometry.Mesh":
brep = rg.Brep.CreateFromMesh(obj, True)
line = find_average_line_between_vertices(brep)
Points = (line.PointAt(0), line.PointAt(1))
elif objType == "Rhino.Geometry.InstanceReferenceGeometry":
rhinoObj = Rhino.RhinoDoc.ActiveDoc.Objects.FindId(objId)
rhinoBrep = None
for obj in rhinoObj.GetSubObjects():
rhinoBrep = Rhino.Geometry.Brep.CreateFromMesh(obj.MeshGeometry, True)
line = find_average_line_between_vertices(rhinoBrep)
Points = (line.PointAt(0), line.PointAt(1))
"""
atts = rhinoObj.Attributes.Duplicate()
for obj in rhinoObj.GetSubObjects():
geom = Rhino.Geometry.Brep.CreateFromMesh(obj.MeshGeometry, True)
if geom:
sc.doc.Objects.AddBrep(geom, atts)
"""
else:
stPt = obj.PathStart
endPt = obj.PathEnd
Points = (stPt, endPt)
return Points
def find_average_line_between_vertices(brep_id):
obj = rs.coercegeometry(brep_id)
vertices = obj.Vertices
pts = [v.Location for v in vertices]
average_line = rg.Line.TryFitLineToPoints(pts)[1]
#sc.doc.Objects.AddLine(average_line)
return average_line
def ConvertToBrep(objId):
obj = rs.coercegeometry(objId)
if str(obj.GetType()) == "Rhino.Geometry.Brep":
return obj
else:
return obj.ToBrep()
def OffsetCurve(id, cover):
obj = rs.coercegeometry(id)
stPt = obj.PathStart
endPt = obj.PathEnd
line = rg.LineCurve(stPt, endPt)
dia = float(rs.GetUserText(id, 'Dimensions|Outside Diameter'))/1000
offsetDistance = dia/2+cover
zMoveVect = rg.Vector3d(0,0,-offsetDistance)
line.Transform(rg.Transform.Translation(zMoveVect))
return [line, offsetDistance]
def ExtrudeElbow(items, extrusionH, tolerance, cover):
offset1 = OffsetCurve(items[0], cover)
curve1 = offset1[0]
offsetDistance1 = offset1[1]
curve2 = OffsetCurve(items[1], cover)[0]
st = curve1.PointAtStart
end = curve1.PointAtEnd
pts = [curve2.PointAtStart, curve2.PointAtEnd]
closest0 = pts[rs.PointArrayClosestPoint(pts, st)]
closest1 = pts[rs.PointArrayClosestPoint(pts, end)]
closest = None
arc = None
if abs(rs.Distance(st, closest0)) < abs(rs.Distance(end, closest1)):
closest = closest0
p = rs.CurveClosestPoint(curve1, st)
arc = rs.AddArcPtTanPt(st, -rs.CurveTangent(curve1, p), closest)
else:
closest = closest1
p = rs.CurveClosestPoint(curve1, end)
arc = rs.AddArcPtTanPt(end, rs.CurveTangent(curve1, p), closest)
arcObj = rs.coercecurve(arc)
extrusion = rg.Extrusion.CreateExtrusion(arcObj, rg.Vector3d(0,0,extrusionH))
brep = rg.Brep.CreateFromOffsetFace(extrusion.ToBrep().Faces[0], offsetDistance1, tolerance, True, True)
#sc.doc.Objects.AddBrep(brep)
return brep
def CreateExtrusions(ids, extrusionH, cover, tolerance ):
#separate extrusions from elbows
extrusionsIds = []
elbows = []
extrudedBreps = []
for id in ids:
obj = rs.coercegeometry(id)
objType = str(obj.GetType())
if objType == "Rhino.Geometry.Brep":
elbows.append(obj)
elif objType == "Rhino.Geometry.Mesh":
brep = rg.Brep.CreateFromMesh(obj, True)
elbows.append(brep)
elif objType == "Rhino.Geometry.InstanceReferenceGeometry":
rhinoObj = Rhino.RhinoDoc.ActiveDoc.Objects.FindId(id)
brep = None
for obj in rhinoObj.GetSubObjects():
brep = Rhino.Geometry.Brep.CreateFromMesh(obj.MeshGeometry, True)
elbows.append(brep)
else:
stPt = obj.PathStart
endPt = obj.PathEnd
extrusionsIds.append(id)
#line_id = rs.AddLine(stPt, endPt)
line = rg.LineCurve(stPt, endPt)
#print line
dia = float(rs.GetUserText(id, 'Dimensions|Outside Diameter'))/1000
offsetDistance = dia/2+cover
zMoveVect = rg.Vector3d(0,0,-offsetDistance)
line.Transform(rg.Transform.Translation(zMoveVect))
#extrusion = rg.Extrusion.Create(line, 10, True)
extrusion = rg.Extrusion.CreateExtrusion(line, rg.Vector3d(0,0,extrusionH))
brep = rg.Brep.CreateFromOffsetFace(extrusion.ToBrep().Faces[0], offsetDistance, tolerance, True, True)
extrudedBreps.append(brep)
#sc.doc.Objects.AddBrep(brep)
counter = 0
for elbow in elbows:
#center = elbow.GetBoundingBox(rg.Plane.WorldXY).Center
connectedExtrusions = []
for extrusionId in extrusionsIds:
extrusion = rs.coercegeometry(extrusionId)
intersCurves = rg.Intersect.Intersection.BrepBrep(elbow, extrusion.ToBrep(), tolerance)[1]
if len(intersCurves)>0:
#excenter = extrusion.ToBrep().GetBoundingBox(rg.Plane.WorldXY).Center
connectedExtrusions.append(extrusionId)
extrudedBreps.append(ExtrudeElbow(connectedExtrusions, extrusionH, tolerance, cover))
#add boolean union
counter += 1
return extrudedBreps
ids = rs.GetObjects("select objects", rs.filter.extrusion+rs.filter.polysurface+rs.filter.mesh+rs.filter.instance)
rs.EnableRedraw(False)
groupedCurves = groupCurves(ids)
index = 0
t = sc.doc.ModelAbsoluteTolerance
c = 0.05 #conduits cover
H = 3 #extrusion H
for g in groupedCurves:
print (str(index))
breps = CreateExtrusions(g, H, c, t)
print (breps)
#rhinoObj = Rhino.RhinoDoc.ActiveDoc.Objects.FindId(breps[0])
union = rg.Brep.CreateBooleanUnion(breps, 0.1)
if union:
sc.doc.Objects.AddBrep(union[0])
else:
for b in breps:
sc.doc.Objects.AddBrep(b)
#union = rg.Brep.JoinBreps(breps, 0.1)
#print (union)
index +=1
rs.EnableRedraw(True)
//https://github.com/mcneel/rhino-developer-samples/blob/7/rhinocommon/cs/SampleCsCommands/SampleCsExplodeBlock.cs
if (x){
// Select a block instance
var go = new GetObject();
go.SetCommandPrompt("Select a block instance to explode");
go.GeometryFilter = ObjectType.InstanceReference;
go.Get();
var iref = go.Object(0).Object();
var xform = Transform.Identity;
if (!(iref is InstanceObject)){
A = "Error";
}
var atts = iref.Attributes.Duplicate();
atts.ObjectId = Guid.Empty;
var objects = iref.GetSubObjects();
foreach (var obj in objects){
var geom = obj.DuplicateGeometry();
doc.Objects.Add(geom, atts);
}
doc.Objects.Delete(go.Object(0), false);
doc.Views.Redraw();
A = objects;
}
else {
A = "waiting...";
}
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import math
def explode_block_instance(goes):
print len(goes.Objects())
for go in goes.Objects():
iref = go.Object()
xform = Rhino.Geometry.Transform.Identity
if not isinstance(iref, Rhino.DocObjects.InstanceObject):
return "Error"
atts = iref.Attributes.Duplicate()
objects = iref.GetSubObjects()
for obj in objects:
geom = Rhino.Geometry.Brep.CreateFromMesh(obj.MeshGeometry, True)
if geom:
sc.doc.Objects.AddBrep(geom, atts)
#sc.doc.Objects.Delete(go, False)
rs.DeleteObject(go)
#sc.doc.Views.Redraw()
return "done"
selection = Rhino.Input.Custom.GetObject()
selection.SetCommandPrompt("Select a block instance to explode")
selection.GeometryFilter = Rhino.DocObjects.ObjectType.InstanceReference
selection.GetMultiple(1,0)
#Rhino.DocObjects.Tables.ObjectTable.Delete(go.Objects()[0].Object()., False)
explode_block_instance(selection)
#equivalent to
ids = rs.GetObject("select extrusion", rs.filter.instance)
rhinoObj = Rhino.RhinoDoc.ActiveDoc.Objects.FindId(ids);
atts = rhinoObj.Attributes.Duplicate()
for obj in rhinoObj.GetSubObjects():
geom = Rhino.Geometry.Brep.CreateFromMesh(obj.MeshGeometry, True)
if geom:
sc.doc.Objects.AddBrep(geom, atts)
rs.Redraw()
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.Geometry as rg
selectedId = rs.GetObject('select start')
selectedObj = rs.coercegeometry(selectedId)
print (selectedObj)
rs.EnableRedraw(False)
#all_object_ids = rs.VisibleObjects()
all_object_ids = rs.AllObjects()
lista = []
for objId in all_object_ids:
line = rs.coercegeometry(objId)
objType = str(line.GetType())
if objType == "Rhino.Geometry.LineCurve":
st = line.PointAtStart
end = line.PointAtEnd
length = rg.LineCurve.GetLength(line, 0.001)
midPt = rg.LineCurve.PointAtLength(line, length*0.5)
#rs.AddTextDot(i, midPt)
lista.append((objId, st, end))
# print('lista')
# for l in lista:
# print (l)
connected = []
queue = set()
for s in lista:
if s[0] == selectedId:
p = lista.pop(lista.index(s))
queue.add(p)
connected.append(p)
break
print ('connected', connected)
while queue:
current = queue.pop()
currentPoints = (current[1], current[2])
for s in lista:
points = (s[1],s[2])
for p1 in currentPoints:
for p2 in points:
distance = rg.Point3d.DistanceTo(p1,p2)
if distance < 0.02 and s not in connected:
queue.add(s)
connected.append(s)
# print ('result', connected)
print (len(connected))
for c in connected:
rs.SelectObject(c[0])
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.Geometry as rg
import Rhino
def GetExtrusionEndPoints(objId):
obj = rs.coercegeometry(objId)
objType = str(obj.GetType())
Points = ()
if objType == "Rhino.Geometry.Brep":
line = find_average_line_between_vertices(objId)
Points = (line.PointAt(0), line.PointAt(1))
elif objType == "Rhino.Geometry.Mesh":
brep = rg.Brep.CreateFromMesh(obj, True)
line = find_average_line_between_vertices(brep)
Points = (line.PointAt(0), line.PointAt(1))
elif objType == "Rhino.Geometry.InstanceReferenceGeometry":
rhinoObj = Rhino.RhinoDoc.ActiveDoc.Objects.FindId(objId)
rhinoBrep = None
for obj in rhinoObj.GetSubObjects():
rhinoBrep = Rhino.Geometry.Brep.CreateFromMesh(obj.MeshGeometry, True)
line = find_average_line_between_vertices(rhinoBrep)
Points = (line.PointAt(0), line.PointAt(1))
elif objType == "Rhino.Geometry.Extrusion":
stPt = obj.PathStart
endPt = obj.PathEnd
Points = (stPt, endPt)
return Points
def find_average_line_between_vertices(brep_id):
obj = rs.coercegeometry(brep_id)
vertices = obj.Vertices
pts = [v.Location for v in vertices]
average_line = rg.Line.TryFitLineToPoints(pts)[1]
#sc.doc.Objects.AddLine(average_line)
return average_line
selectedId = rs.GetObject('select start')
selectedObj = rs.coercegeometry(selectedId)
print (selectedObj)
rs.EnableRedraw(False)
all_object_ids = rs.VisibleObjects()
#all_object_ids = rs.AllObjects()
lista = []
filterTypes= ["Rhino.Geometry.Extrusion", "Rhino.Geometry.Brep", "Rhino.Geometry.InstanceReferenceGeometry"]
for objId in all_object_ids:
obj = rs.coercegeometry(objId)
objType = str(obj.GetType())
points = GetExtrusionEndPoints(objId)
if points:
lista.append((objId, points[0], points[1]))
# for l in lista[0:10]:
# print (l)
connected = []
queue = set()
for s in lista:
if s[0] == selectedId:
p = lista.pop(lista.index(s))
queue.add(p)
connected.append(p)
break
print ('connected', connected)
while queue:
current = queue.pop()
currentPoints = (current[1], current[2])
for s in lista:
points = (s[1],s[2])
for p1 in currentPoints:
for p2 in points:
distance = rg.Point3d.DistanceTo(p1,p2)
if distance < 0.08 and s not in connected:
queue.add(s)
connected.append(s)
# print ('result', connected)
print (len(connected))
for c in connected:
rs.SelectObject(c[0])
"""Provides a scripting component.
Inputs:
x: The x script variable
y: The y script variable
Output:
a: The a output variable"""
__author__ = "G"
__version__ = "2023.06.06"
import rhinoscriptsyntax as rs
import Rhino
from math import pow
import ghpythonlib.treehelpers as th
newVertexes = []
lines = []
newCurves = [crv[0]]
currentCrv = crv[0]
for i in range(0,len(crv)-1):
print '##################curve ' + str(i)
subVert = []
subLines = []
divisionPoints = None
if rs.CurveLength(crv[i]) > 1.1:
divisionPoints = rs.DivideCurveEquidistant(crv[i+1],1)
else:
divisionPoints = rs.DivideCurve(crv[i+1],3)
#for pt in crv[i+1].ToPolyline().ToArray():
for pt in divisionPoints:
#point on previous curve
pt0 = currentCrv.PointAt(rs.CurveClosestPoint(currentCrv, pt))
run = pow( pow(pt0.X-pt.X,2) + pow(pt0.Y-pt.Y,2) , 0.5)
rise = abs( pt0.Z - pt.Z )
print 'initial rise ' + str(round(run,2))
slope = rise/run*100
print 'initial slope ' + str(round (slope,2))+ '%'
newPt = pt
counter = 0
while counter < 100:
print '****************************************counter' + str(counter)
print '*****************new slope ' + str(slope)
if (slope > 3):
print 'slope higher than 3%!!!'
#newPt = rs.coerce3dpoint(rs.AddPoint(pt.X, pt.Y, pt.Z + run * 0.03))
newPt = rs.coerce3dpoint(rs.AddPoint(newPt.X, newPt.Y, newPt.Z + 0.01))
print 'point Z ' + str(newPt.Z)
newRise = abs( pt0.Z - newPt.Z )
print 'new rise' + str(newRise)
slope = newRise/run*100
print 'new slope ' + str(round(slope,2)) + '%'
counter +=1
subVert.append(newPt)
subLines.append(rs.AddLine(pt0, newPt))
#print subVert
currentCrv = rs.coercecurve( rs.AddPolyline(subVert) )
newVertexes.append(subVert)
lines.append(subLines)
newCurves.append(currentCrv)
newVertexes = th.list_to_tree(newVertexes, source=[0,0])
lines = th.list_to_tree(lines, source=[0,0])
newPt = newVertexes
slope = lines
curves = newCurves
Rhino.ApplicationSettings.AppearanceSettings.MenuVisible = false;
Rhino.ApplicationSettings.AppearanceSettings.ShowSideBar = false;
Rhino.ApplicationSettings.AppearanceSettings.ShowOsnapBar = false;
Rhino.ApplicationSettings.AppearanceSettings.ShowStatusBar = false;
Rhino.ApplicationSettings.AppearanceSettings.ShowFullPathInTitleBar = false;
for (int i = 0; i < RhinoApp.ToolbarFiles.Count; i++)
{
RhinoApp.ToolbarFiles[i].Close(false);
}
foreach (var panel in Rhino.UI.Panels.GetOpenPanelIds())
{
Rhino.UI.Panels.ClosePanel(panel);
}
var view = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
int index = Rhino.RhinoDoc.ActiveDoc.NamedViews.FindByName("Perspective");
Rhino.RhinoDoc.ActiveDoc.NamedViews.Restore(index, view.ActiveViewport);
view.Maximized = true;
view.Redraw();
RhinoApp.RunScript("-_CommandPrompt _Show _No _Enter", false);
//Rhino.ApplicationSettings.AppearanceSettings.CommandPromptPosition = Rhino.ApplicationSettings.CommandPromptPosition.Hidden;
#credits: https://discourse.mcneel.com/t/import-dxf-files-in-rhino-and-reference-the-geometry/78832
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino,os
selectedFiles = rs.OpenFileNames("Import files", None,r"C:\OneDrive");
for file in selectedFiles:
filename = file.split("\\")[-1]
fullpath=file
obj_count=0
file_count=0
raise_copy_count=False
#get existing layer set
exist_layers=set(rs.LayerNames())
#import file
print "Importing " + filename
rs.Command('_-Import "{}" _Enter'.format(fullpath), False)
if rs.LastCommandResult()==0: file_count+=1
lco = rs.LastCreatedObjects(False)
if lco: obj_count+=len(lco)
#get all newly imported layers
imp_layers=set(rs.LayerNames()).difference(exist_layers)
#Some file formats (STEP) can be "layerless"! imp_layers will have len==0
#create new parent layer with filename
if not rs.IsLayer(filename):
p_layer=rs.AddLayer(filename)
else:
#add suffix to make parent layer unique
p_layer=rs.AddLayer(AddNumberSuffix(filename,copy_count))
raise_copy_count=True
#try to transfer layers to new parent
if len(imp_layers)==0:
#need to transfer imported objects to newly created parent layer
rs.ObjectLayer(lco,p_layer)
else:
for imp_layer in imp_layers:
try:
if not rs.ParentLayer(imp_layer):
rs.ParentLayer(imp_layer,p_layer)
except: pass
rs.ExpandLayer(filename, False)
rs.ZoomExtents()
//------------------------------------------------------------------
// NavisWorks Sample code
//------------------------------------------------------------------
// (C) Copyright 2010 by Autodesk Inc.
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//------------------------------------------------------------------
//
// This sample compares the time it takes to find ModelItems in a
// model using various search methods.
//
//------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Plugins;
using ComApi = Autodesk.Navisworks.Api.Interop.ComApi;
using ComApiBridge = Autodesk.Navisworks.Api.ComApi;
namespace SearchComparisonPlugIn
{
[PluginAttribute("SearchComparisonPlugIn.SearchComparisonPlugIn", "ADSK",
DisplayName="Search Comparison",
ToolTip="Compares the time taken for different search techniques on a Navisworks Document")]
public class SearchComparisonPlugIn : AddInPlugin
{
public static double[] Elements;
public override int Execute(params string[] parameters)
{
//ComApi.InwOpState10 state;
//state = ComApiBridge.ComApiBridge.State;
//foreach (ComApi.InwOaPath path in state.CurrentSelection.Paths())
//{
// ComApi.InwOaNode node;
// node = path.Nodes().Last() as ComApi.InwOaNode;
// MessageBox.Show("UserName=" + node.UserName);
//}
ModelItemCollection oModelColl = Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems;
//convert to COM selection
ComApi.InwOpState oState = ComApiBridge.ComApiBridge.State;
ComApi.InwOpSelection oSel = ComApiBridge.ComApiBridge.ToInwOpSelection(oModelColl);
CallbackGeomListener callbkListener = new CallbackGeomListener();
foreach (ComApi.InwOaPath3 path in oSel.Paths())
{
foreach (ComApi.InwOaFragment3 frag in path.Fragments())
{
// https://forums.autodesk.com/t5/navisworks-api/geometry-in-wrong-location-when-accessing-in-api/m-p/5896205/highlight/true
// https://github.com/jotpunktbee/SpeckleNavisworks/blob/08204aed7ee9f99d8b5ba50c5df102a4c95907a2/SpeckleNavisworks/Models/SearchComparisonPlugIn.cs
ComApi.InwLTransform3f3 localToWorld = (ComApi.InwLTransform3f3)(object)frag.GetLocalToWorldMatrix();
Array localToWorldMatrix = (Array)(object)localToWorld.Matrix;
Elements = ToArray<double>(localToWorldMatrix);
callbkListener.LCS2WCS = localToWorld;
// generate the primitives
frag.GenerateSimplePrimitives(ComApi.nwEVertexProperty.eNORMAL, callbkListener);
}
}
var result = callbkListener.coords;
Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
Selection storedSelection = new Selection();
storedSelection = new Selection();
storedSelection.CopyFrom(doc.CurrentSelection.ToSelection());
ModelGeometry geom = storedSelection.ExplicitSelection.First.Geometry;
//int count = geom.PrimitiveCount;
Point3D bb3dcenter = storedSelection.GetSelectedItems().BoundingBox().Center;
#region
StringBuilder output = new StringBuilder(1000);
output.Append("Searching for Visible ModelItems which contain geometry, returning a ModelItemCollection\n");
output.Append("Time format is (mm:ss.fff)\n");
/////////////////////////////////////////////////////////////////////////////
//iterative method
DateTime start = DateTime.Now;
ModelItemCollection searchResults = new ModelItemCollection();
foreach (ModelItem modelItem in Autodesk.Navisworks.Api.Application.ActiveDocument.Models.CreateCollectionFromRootItems().DescendantsAndSelf)
{
//find the model items with the Geometry, not hidden
if (modelItem.HasGeometry && !modelItem.IsHidden)
searchResults.Add(modelItem);
}
DateTime end = DateTime.Now;
DateTime taken = new DateTime(end.Ticks - start.Ticks);
output.Append("Iterative method\t");
output.Append(taken.ToString("mm:ss.fff"));
output.Append(" to find ");
output.Append(searchResults.Count);
output.Append(" ModelItems\n");
/////////////////////////////////////////////////////////////////////////////
//using LINQ style query
start = DateTime.Now;
ModelItemCollection searchResults1 = new ModelItemCollection();
searchResults1.CopyFrom(
Autodesk.Navisworks.Api.Application.ActiveDocument.Models.RootItemDescendantsAndSelf.
Where(x =>
//find the ModelItems with the Geometry, not hidden
(x.HasGeometry && !x.IsHidden)));
end = DateTime.Now;
taken = new DateTime(end.Ticks - start.Ticks);
output.Append("LINQ query\t");
output.Append(taken.ToString("mm:ss.fff"));
output.Append(" to find ");
output.Append(searchResults1.Count);
output.Append(" ModelItems\n");
/////////////////////////////////////////////////////////////////////////////
//Searching purely with Search class
start = DateTime.Now;
//Create a new search
Search s2 = new Search();
//Add a search condition for ModelItems with Geometry only...
s2.SearchConditions.Add(SearchCondition.HasCategoryByName(PropertyCategoryNames.Geometry));
//...and not hidden
s2.SearchConditions.Add(SearchCondition.HasPropertyByName(PropertyCategoryNames.Item, DataPropertyNames.ItemHidden).EqualValue(VariantData.FromBoolean(false)));
//set the selection to everything
s2.Selection.SelectAll();
s2.Locations = SearchLocations.DescendantsAndSelf;
//get the resulting collection by applying this search
ModelItemCollection searchResults2 = s2.FindAll(Autodesk.Navisworks.Api.Application.ActiveDocument, false);
end = DateTime.Now;
taken = new DateTime(end.Ticks - start.Ticks);
output.Append("Search query\t");
output.Append(taken.ToString("mm:ss.fff"));
output.Append(" to find ");
output.Append(searchResults2.Count);
output.Append(" ModelItems\n");
/////////////////////////////////////////////////////////////////////////////
//Mixture search
start = DateTime.Now;
//Create a new search
Search s3 = new Search();
//Add a search condition for those ModelItems with Geometry
s3.SearchConditions.Add(SearchCondition.HasCategoryByName(PropertyCategoryNames.Geometry));
//set the selection to everything
s3.Selection.SelectAll();
s3.Locations = SearchLocations.DescendantsAndSelf;
//get the resulting collection by applying this search
ModelItemCollection searchResults3 = new ModelItemCollection();
searchResults3.CopyFrom(
s3.FindIncremental(Autodesk.Navisworks.Api.Application.ActiveDocument, false)
.Where(x =>
//find the model items, not hidden
(!x.IsHidden)));
end = DateTime.Now;
taken = new DateTime(end.Ticks - start.Ticks);
output.Append("Mixed query\t");
output.Append(taken.ToString("mm:ss.fff"));
output.Append(" to find ");
output.Append(searchResults3.Count);
output.Append(" ModelItems\n");
#endregion
//MessageBox.Show(output.ToString());
MessageBox.Show("Ciao da visual studoi");
return 0;
}
public T[] ToArray<T>(Array arr)
{
T[] result = new T[arr.Length];
Array.Copy(arr, result, result.Length);
return result;
}
}
class CallbackGeomListener : ComApi.InwSimplePrimitivesCB
{
public ComApi.InwLTransform3f3 LCS2WCS;
public List<string> coords = new List<string>();
public void Line(ComApi.InwSimpleVertex v1, ComApi.InwSimpleVertex v2)
{
// do your work
//Array array_v1 = (Array)(object)v1.coord;
//coords.Add($"{array_v1.GetValue(1)},{array_v1.GetValue(2)},{array_v1.GetValue(3)}");
//Array array_v2 = (Array)(object)v2.coord;
//2
Array array_v1 = (Array)(object)v1.coord;
Array array_v2 = (Array)(object)v2.coord;
double w = (SearchComparisonPlugIn.Elements[3] * Convert.ToDouble(array_v1.GetValue(1))) +
(SearchComparisonPlugIn.Elements[7] * Convert.ToDouble(array_v1.GetValue(2))) +
(SearchComparisonPlugIn.Elements[11] * Convert.ToDouble(array_v1.GetValue(3))) +
SearchComparisonPlugIn.Elements[15];
double newPointX = ((SearchComparisonPlugIn.Elements[0] * Convert.ToDouble(array_v1.GetValue(1))) + (SearchComparisonPlugIn.Elements[4] * Convert.ToDouble(array_v1.GetValue(2))) + (SearchComparisonPlugIn.Elements[8] * Convert.ToDouble(array_v1.GetValue(3))) + SearchComparisonPlugIn.Elements[12]) / w;
double newPointY = ((SearchComparisonPlugIn.Elements[1] * Convert.ToDouble(array_v1.GetValue(1))) + (SearchComparisonPlugIn.Elements[5] * Convert.ToDouble(array_v1.GetValue(2))) + (SearchComparisonPlugIn.Elements[9] * Convert.ToDouble(array_v1.GetValue(3))) + SearchComparisonPlugIn.Elements[13]) / w;
double newPointZ = ((SearchComparisonPlugIn.Elements[2] * Convert.ToDouble(array_v1.GetValue(1))) + (SearchComparisonPlugIn.Elements[6] * Convert.ToDouble(array_v1.GetValue(2))) + (SearchComparisonPlugIn.Elements[10] * Convert.ToDouble(array_v1.GetValue(3))) + SearchComparisonPlugIn.Elements[14]) / w;
double w2 = (SearchComparisonPlugIn.Elements[3] * Convert.ToDouble(array_v2.GetValue(1))) +
(SearchComparisonPlugIn.Elements[7] * Convert.ToDouble(array_v2.GetValue(2))) +
(SearchComparisonPlugIn.Elements[11] * Convert.ToDouble(array_v2.GetValue(3))) +
SearchComparisonPlugIn.Elements[15];
double newPoint2X = ((SearchComparisonPlugIn.Elements[0] * Convert.ToDouble(array_v2.GetValue(1))) + (SearchComparisonPlugIn.Elements[4] * Convert.ToDouble(array_v2.GetValue(2))) + (SearchComparisonPlugIn.Elements[8] * Convert.ToDouble(array_v2.GetValue(3))) + SearchComparisonPlugIn.Elements[12]) / w2;
double newPoint2Y = ((SearchComparisonPlugIn.Elements[1] * Convert.ToDouble(array_v2.GetValue(1))) + (SearchComparisonPlugIn.Elements[5] * Convert.ToDouble(array_v2.GetValue(2))) + (SearchComparisonPlugIn.Elements[9] * Convert.ToDouble(array_v2.GetValue(3))) + SearchComparisonPlugIn.Elements[13]) / w2;
double newPoint2Z = ((SearchComparisonPlugIn.Elements[2] * Convert.ToDouble(array_v2.GetValue(1))) + (SearchComparisonPlugIn.Elements[6] * Convert.ToDouble(array_v2.GetValue(2))) + (SearchComparisonPlugIn.Elements[10] * Convert.ToDouble(array_v2.GetValue(3))) + SearchComparisonPlugIn.Elements[14]) / w2;
coords.Add($"{newPointX},{newPointY},{newPointZ}");
coords.Add($"{newPoint2X},{newPoint2Y},{newPoint2Z}");
}
public void Point(ComApi.InwSimpleVertex v1)
{
// do your work
}
public void SnapPoint(ComApi.InwSimpleVertex v1)
{
// do your work
}
public void Triangle(ComApi.InwSimpleVertex v1, ComApi.InwSimpleVertex v2, ComApi.InwSimpleVertex v3)
{
// do your work
}
}
}
__author__ = "GBrogiolo"
__version__ = "2023.08.09"
import rhinoscriptsyntax as rs
import Rhino
for i in x:
rhinoObj = Rhino.RhinoDoc.ActiveDoc.Objects.FindId(i)
print rhinoObj.GetType()
if "Extrusion" in str(rhinoObj.GetType()):
print 'found'
dia = rs.GetUserText(rhinoObj, "Dimensions|Outside Diameter", False)
else:
curve = i
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import math
def OffsetCurve(id):
obj = rs.coercegeometry(id)
stPt = obj.PathStart
endPt = obj.PathEnd
line = Rhino.Geometry.LineCurve(stPt, endPt)
dia = float(rs.GetUserText(id, 'Dimensions|Outside Diameter'))/1000
offsetDistance = dia/2+cover
zMoveVect = Rhino.Geometry.Vector3d(0,0,-offsetDistance)
line.Transform(Rhino.Geometry.Transform.Translation(zMoveVect))
return [line, offsetDistance]
def ExtrudeElbow(items, extrusionH, tolerance):
offset1 = OffsetCurve(items[0])
curve1 = offset1[0]
offsetDistance1 = offset1[1]
curve2 = OffsetCurve(items[1])[0]
st = curve1.PointAtStart
end = curve1.PointAtEnd
pts = [curve2.PointAtStart, curve2.PointAtEnd]
closest0 = pts[rs.PointArrayClosestPoint(pts, st)]
closest1 = pts[rs.PointArrayClosestPoint(pts, end)]
closest = None
arc = None
if abs(rs.Distance(st, closest0)) < abs(rs.Distance(end, closest1)):
closest = closest0
p = rs.CurveClosestPoint(curve1, st)
arc = rs.AddArcPtTanPt(st, -rs.CurveTangent(curve1, p), closest)
else:
closest = closest1
p = rs.CurveClosestPoint(curve1, end)
arc = rs.AddArcPtTanPt(end, rs.CurveTangent(curve1, p), closest)
arcObj = rs.coercecurve(arc)
extrusion = Rhino.Geometry.Extrusion.CreateExtrusion(arcObj, Rhino.Geometry.Vector3d(0,0,extrusionH))
brep = Rhino.Geometry.Brep.CreateFromOffsetFace(extrusion.ToBrep().Faces[0], offsetDistance1, tolerance, True, True)
sc.doc.Objects.AddBrep(brep)
tolerance = sc.doc.ModelAbsoluteTolerance
cover = 0.05
ids = rs.GetObjects("select extrusion", rs.filter.extrusion+rs.filter.polysurface)
extrusionH = 3
rs.EnableRedraw(enable=False)
#separate extrusions from elbows
extrusionsIds = []
elbows = []
for id in ids:
obj = rs.coercegeometry(id)
if str(obj.GetType()) == "Rhino.Geometry.Brep":
elbows.append(obj)
else:
stPt = obj.PathStart
endPt = obj.PathEnd
extrusionsIds.append(id)
#line_id = rs.AddLine(stPt, endPt)
line = Rhino.Geometry.LineCurve(stPt, endPt)
#print line
dia = float(rs.GetUserText(id, 'Dimensions|Outside Diameter'))/1000
offsetDistance = dia/2+cover
zMoveVect = Rhino.Geometry.Vector3d(0,0,-offsetDistance)
line.Transform(Rhino.Geometry.Transform.Translation(zMoveVect))
# SET EXTRUSION HEIGHT
#extrusion = Rhino.Geometry.Extrusion.Create(line, 10, True)
extrusion = Rhino.Geometry.Extrusion.CreateExtrusion(line, Rhino.Geometry.Vector3d(0,0,extrusionH))
brep = Rhino.Geometry.Brep.CreateFromOffsetFace(extrusion.ToBrep().Faces[0], offsetDistance, tolerance, True, True)
sc.doc.Objects.AddBrep(brep)
counter = 0
for elbow in elbows:
center = elbow.GetBoundingBox(Rhino.Geometry.Plane.WorldXY).Center
#rs.AddTextDot('elbow: '+str(counter), center)
connectedExtrusions = []
for extrusionId in extrusionsIds:
extrusion = rs.coercegeometry(extrusionId)
intersCurves = Rhino.Geometry.Intersect.Intersection.BrepBrep(elbow, extrusion.ToBrep(), tolerance)[1]
if len(intersCurves)>0:
excenter = extrusion.ToBrep().GetBoundingBox(Rhino.Geometry.Plane.WorldXY).Center
connectedExtrusions.append(extrusionId)
#rs.AddTextDot(counter, excenter)
ExtrudeElbow(connectedExtrusions,extrusionH,tolerance)
counter += 1
import rhinoscriptsyntax as rs
import csv
#destination csv file
filename = 'C:\\temp\\ElementiNuovi_Excel.csv'
#pick the lines you want to export
selectedLines = rs.GetObjects('Select lines', rs.filter.curve)
#array to store the points ids and coordinates
points = [['Joint', 'CoordSys', 'CoordType', 'XorR', 'Y', 'T', 'Z']]
for l in selectedLines:
attributes = rs.ObjectName(l).split(',')
jI = attributes[0]
jJ = attributes[1]
frame = attributes[2]
stDot = rs.AddTextDot(jI, rs.CurveStartPoint(l))
rs.ObjectColor(stDot, (0,255,0))
points.append([jI, 'GLOBAL', 'Cartesian', rs.CurveStartPoint(l).X,rs.CurveStartPoint(l).Y,'',rs.CurveStartPoint(l).Z])
endDot = rs.AddTextDot(jJ, rs.CurveEndPoint(l))
rs.ObjectColor(endDot, (0,0,255))
points.append([jJ, 'GLOBAL', 'Cartesian', rs.CurveStartPoint(l).X,rs.CurveStartPoint(l).Y,'',rs.CurveStartPoint(l).Z])
frameDot = rs.AddTextDot(frame, rs.CurveMidPoint(l))
rs.ObjectColor(frameDot, (255,0,0))
with open(filename, "wb") as csvfile:
csvwriter = csv.writer(csvfile, delimiter=',')
for point in points:
csvwriter.writerow(point)
print "Points sucessfully written to file"
import rhinoscriptsyntax as rs
import csv
#update the view once all the geometry is computed (faster)
rs.EnableRedraw(False)
#get all the points from SAP
points = []
#https://developer.rhino3d.com/guides/rhinopython/python-csv-file/
with open('C:\\temp\\Nodi_Excel.csv') as csvfile:
reader = csv.reader(csvfile)
reader.next() #skip first row TABLE:
reader = csv.DictReader(csvfile)
for row in reader:
if (row['Joint']):
points.append({'Joint': int(row['Joint']),'X':float(row['XorR']),'Y':float(row['Y']),'Z':float(row['Z'])})
"""
print points
for p in points:
rs.AddPoint(p['X'],p['Y'],p['Z'])
"""
#get all the elementfrom SAP
elements = []
#https://developer.rhino3d.com/guides/rhinopython/python-csv-file/
with open('C:\\temp\\Elementi_Excel.csv') as csvfile:
reader = csv.reader(csvfile)
reader.next() #skip first row TABLE:
reader = csv.DictReader(csvfile)
for row in reader:
if row['Frame']:
elements.append({'Frame': int(row['Frame']),'JointI':int(row['JointI']),'JointJ':int(row['JointJ'])}) #assume all straight lines, no curves
for e in elements:
#print e
jI = e['JointI']
jJ = e['JointJ']
ptI = None
ptJ = None
# find the point that matches jI or jJ
for p in points:
currentJoint = p['Joint']
if currentJoint == jI:
ptI = [p['X'],p['Y'],p['Z']]
elif currentJoint == jJ:
ptJ = [p['X'],p['Y'],p['Z']]
#if both points exists, create a line. Write start point, end point and frame ID in the object name
if ptI and ptJ:
line = rs.AddLine(ptI, ptJ)
rs.ObjectName(line, str(jI) + ',' + str(jJ) + "," + str(e['Frame']))
using System;
using System.Collections;
using System.Collections.Generic;
using Rhino;
using Rhino.Geometry;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
/// <summary>
/// This class will be instantiated on demand by the Script component.
/// </summary>
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
/// <summary>Print a String to the [Out] Parameter of the Script component.</summary>
/// <param name="text">String to print.</param>
private void Print(string text) { /* Implementation hidden. */ }
/// <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>
/// <param name="format">String format.</param>
/// <param name="args">Formatting parameters.</param>
private void Print(string format, params object[] args) { /* Implementation hidden. */ }
/// <summary>Print useful information about an object instance to the [Out] Parameter of the Script component. </summary>
/// <param name="obj">Object instance to parse.</param>
private void Reflect(object obj) { /* Implementation hidden. */ }
/// <summary>Print the signatures of all the overloads of a specific method to the [Out] Parameter of the Script component. </summary>
/// <param name="obj">Object instance to parse.</param>
private void Reflect(object obj, string method_name) { /* Implementation hidden. */ }
#endregion
#region Members
/// <summary>Gets the current Rhino document.</summary>
private readonly RhinoDoc RhinoDocument;
/// <summary>Gets the Grasshopper document that owns this script.</summary>
private readonly GH_Document GrasshopperDocument;
/// <summary>Gets the Grasshopper script component that owns this script.</summary>
private readonly IGH_Component Component;
/// <summary>
/// Gets the current iteration count. The first call to RunScript() is associated with Iteration==0.
/// Any subsequent call within the same solution will increment the Iteration count.
/// </summary>
private readonly int Iteration;
#endregion
/// <summary>
/// This procedure contains the user code. Input parameters are provided as regular arguments,
/// Output parameters as ref arguments. You don't have to assign output parameters,
/// they will have a default value.
/// </summary>
private void RunScript(bool x, ref object A, ref object B, ref object C, ref object D, ref object E)
{
if (x){
Rhino.Input.Custom.GetObject goMesh = new Rhino.Input.Custom.GetObject();
goMesh.SetCommandPrompt("Select mesh");
goMesh.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh;
goMesh.SubObjectSelect = false;
goMesh.GroupSelect = false;
goMesh.Get();
Rhino.DocObjects.ObjRef objrefMesh = goMesh.Object(0);
Rhino.Geometry.Mesh signalMesh = objrefMesh.Mesh();
Rhino.Geometry.Point3d signalBBoxCenter = signalMesh.GetBoundingBox(true).Center;
double radius = 0.75;
Rhino.Geometry.Sphere sphere = new Rhino.Geometry.Sphere(signalBBoxCenter, radius);
A = sphere;
Rhino.Input.Custom.GetObject goCurve = new Rhino.Input.Custom.GetObject();
goCurve.SetCommandPrompt("Select alignment");
goCurve.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
goCurve.SubObjectSelect = false;
goCurve.GroupSelect = false;
goCurve.Get();
Rhino.DocObjects.ObjRef objrefCurve = goCurve.Object(0);
Rhino.Geometry.Curve alignmentCurve = objrefCurve.Curve();
B = alignmentCurve;
double t = 0;
alignmentCurve.ClosestPoint(signalBBoxCenter, out t);
Rhino.Geometry.Point3d pointOnAlignment = alignmentCurve.PointAt(t);
Rhino.Geometry.Curve splitAlignment = alignmentCurve.Split(t)[1];
double speed = 80; //km/h
int travelTime = 10; //seconds
double distance = speed * 1000 / 3600; //distance per second
double driverHeight = 2.7; //above rail
Rhino.Geometry.Point3d[] viewPoints = splitAlignment.DivideEquidistant(distance);
Point3d[] travelPoints = new Point3d[travelTime + 1];
Array.Copy(viewPoints, travelPoints, travelTime + 1);
C = travelPoints;
Line[] sightLines = new Line[travelTime];
Vector3d up = new Vector3d(0, 0, -1);
Vector3d[] directions = new Vector3d[travelTime];
string[] xmlViewpoints = new string[travelTime];
for (int i = travelTime; i > 0; i--)
{
Point3d driverView = new Point3d(travelPoints[i].X, travelPoints[i].Y, travelPoints[i].Z + driverHeight);
Point3d nextDriverView = new Point3d(travelPoints[i - 1].X, travelPoints[i - 1].Y, travelPoints[i - 1].Z + driverHeight);
Line line = new Line(driverView, nextDriverView);
sightLines.SetValue(line, i - 1);
Vector3d direction = nextDriverView - driverView;
//Vector3d direction = line.Direction;
directions.SetValue(direction, i - 1);
direction.Unitize();
Vector3d xaxis = Vector3d.CrossProduct(up, direction);
Vector3d yaxis = Vector3d.CrossProduct(direction, xaxis);
xaxis.Unitize();
yaxis.Unitize();
List<double[]> m = new List<double[]>();
double[] m0 = new double[3];
double[] m1 = new double[3];
double[] m2 = new double[3];
m0.SetValue(xaxis.X, 0);
m0.SetValue(yaxis.X, 1);
m0.SetValue(direction.X, 2);
m1.SetValue(xaxis.Y, 0);
m1.SetValue(yaxis.Y, 1);
m1.SetValue(direction.Y, 2);
m2.SetValue(xaxis.Z, 0);
m2.SetValue(yaxis.Z, 1);
m2.SetValue(direction.Z, 2);
m.Add(m0);
m.Add(m1);
m.Add(m2);
double qw = Math.Sqrt(1 + m[0][0] + m[1][1] + m[2][2]) / 2;
double qz = -(m[2][1] - m[1][2]) / (4 * qw);
double qy = -(m[0][2] - m[2][0]) / ( 4 * qw);
double qx = (m[1][0] - m[0][1]) / ( 4 * qw);
string quaternion = String.Format(" <quaternion a=\"{0}\" b=\"{1}\" c=\"{2}\" d=\"{3}\"/>", qw, qx, qy, qz);
string position = String.Format("<pos3f x=\"{0}\" y=\"{1}\" z=\"{2}\"/>", driverView.X, driverView.Y, driverView.Z);
string view = String.Format("<view name=\"{0}\">\n" +
" <viewpoint tool = \"none\" render = \"preview\" lighting = \"headlight\" linear = \"22.2222891780\" angular = \"0.0771756700\"> \n" +
" <camera projection = \"persp\" near = \"1.0000000000\" far = \"10.0000000000\" aspect = \"1.0000000000\" height = \"0.7853980000\"> \n" +
" <position>\n" +
" {1}\n" +
" </position>\n" +
" <rotation>\n" +
" {2}\n" +
" </rotation>\n" +
" </camera>\n" +
" </viewpoint>\n" +
"</view>\n", i * distance, position, quaternion);
xmlViewpoints.SetValue(view, travelTime - i);
}
Guid g = Guid.NewGuid();
string xmlAnimation = String.Format("<animation name=\"{0}\" guid=\"{1}\">\n" +
" {2}\n" +
"</animation>", "Animation Name", g, string.Join("\n", xmlViewpoints));
E = xmlAnimation;
D = sightLines;
}
else
{
A = "Set true to run";
}
}
// <Custom additional code>
// </Custom additional code>
}
"""
reference:
https://forums.autodesk.com/t5/navisworks-forum/quaternion-function-for-viewpoint-export-import/td-p/2687701
"""
__author__ = "G"
__version__ = "2022.11.17"
import rhinoscriptsyntax as rs
import math
#xaxis = Vector.Normalized(Vector.Cross(up, direction))
xaxis = rs.VectorUnitize( rs.VectorCrossProduct(up,direction) )
#yaxis = Vector.Normalized(Vector.Cross(direction,xaxis))
yaxis = rs.VectorUnitize( rs.VectorCrossProduct(direction, xaxis) )
m = [[] for j in range(3)]
#row1
m[0].append(xaxis.X)
m[0].append(yaxis.X)
m[0].append(direction.X)
#row2
m[1].append(xaxis.Y)
m[1].append(yaxis.Y)
m[1].append(direction.Y)
#row3
m[2].append(xaxis.Z)
m[2].append(yaxis.Z)
m[2].append(direction.Z)
qw = math.sqrt(1 + m[0][0] + m[1][1] + m[2][2])/2
qz = -(m[2][1] - m[1][2]) / (4*qw)
qy = -(m[0][2] - m[2][0])/( 4 *qw)
qx = (m[1][0] - m[0][1])/( 4 *qw)
a = qw
b = qx
c = qy
d = qz
xml = '<quaternion a="{a}" b="{b}" c="{c}" d="{d}"/>'.format(a=qw,b=qx,c=qy,d=qz)
<?xml version="1.0" encoding="UTF-8" ?>
<exchange xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://download.autodesk.com/us/navisworks/schemas/nw-exchange-12.0.xsd" units="m" filename="" filepath="">
<viewpoints>
<animation name="_Default" guid="6d1c964c-2b71-4f7e-863a-08b9da8ac9b2">
<view name="_Default_222">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="345028.699749" y="5812832.91015" z="130.199903282"/>
</position>
<rotation>
<quaternion a="0.698754957505" b="0.151779899758" c="0.148388872071" d="0.683143553023"/>
</rotation>
</camera>
</viewpoint>
</view>
<view name="_Default_200">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="345028.699749" y="5812832.91015" z="130.199903282"/>
</position>
<rotation>
<quaternion a="0.698754957505" b="0.151779899758" c="0.148388872071" d="0.683143553023"/>
</rotation>
</camera>
</viewpoint>
</view>
<view name="_Default_178">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="345028.699749" y="5812832.91015" z="130.199903282"/>
</position>
<rotation>
<quaternion a="0.698754957505" b="0.151779899758" c="0.148388872071" d="0.683143553023"/>
</rotation>
</camera>
</viewpoint>
</view>
<view name="_Default_156">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="345028.699749" y="5812832.91015" z="130.199903282"/>
</position>
<rotation>
<quaternion a="0.698754957505" b="0.151779899758" c="0.148388872071" d="0.683143553023"/>
</rotation>
</camera>
</viewpoint>
</view>
<view name="_Default_133">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="345028.699749" y="5812832.91015" z="130.199903282"/>
</position>
<rotation>
<quaternion a="0.698754957505" b="0.151779899758" c="0.148388872071" d="0.683143553023"/>
</rotation>
</camera>
</viewpoint>
</view>
<view name="_Default_111">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="345028.699749" y="5812832.91015" z="130.199903282"/>
</position>
<rotation>
<quaternion a="0.698754957505" b="0.151779899758" c="0.148388872071" d="0.683143553023"/>
</rotation>
</camera>
</viewpoint>
</view>
<view name="_Default_089">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="345019.483332" y="5812853.12416" z="130.701917806"/>
</position>
<rotation>
<quaternion a="0.699570652419" b="0.151976964876" c="0.148225026137" d="0.682299967791"/>
</rotation>
</camera>
</viewpoint>
</view>
<view name="_Default_067">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="345010.266098" y="5812873.33706" z="131.257299826"/>
</position>
<rotation>
<quaternion a="0.697570383484" b="0.15202891007" c="0.149102471004" d="0.684142692521"/>
</rotation>
</camera>
</viewpoint>
</view>
<view name="_Default_044">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="345001.022401" y="5812893.53669" z="131.689102470"/>
</position>
<rotation>
<quaternion a="0.692313759095" b="0.154616986866" c="0.153629123869" d="0.687890499018"/>
</rotation>
</camera>
</viewpoint>
</view>
<view name="_Default_022">
<viewpoint tool="none" render="preview" lighting="headlight" linear="22.2222891780" angular="0.0771756700">
<camera projection="persp" near="1.0000000000" far="10.0000000000" aspect="1.0000000000" height="0.7853980000">
<position>
<pos3f x="344991.573770" y="5812913.63521" z="131.831452336"/>
</position>
<rotation>
<quaternion a="0.686402474227" b="0.159744236067" c="0.160812799951" d="0.690993969431"/>
</rotation>
</camera>
</viewpoint>
</view>
</animation>
</viewpoints>
</exchange>
# Follow this: https://discourse.mcneel.com/t/howto-run-c-script-in-rhino-using-vs-code/87642
# then update the .csproj dll file paths
# and target framework see: https://docs.microsoft.com/en-us/dotnet/standard/frameworks
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
</PropertyGroup>
<ItemGroup>
<Reference Include="Grasshopper">
<HintPath>C:\Program Files\Rhino 7\Plug-ins\Grasshopper\Grasshopper.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RhinoCommon">
<HintPath>C:\Program Files\Rhino 7\System\RhinoCommon.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment