Hi guys, as the title is saying, this look so easy to achieve, yet i simply cannot get it to work.
This is how it looks in C#
public void SetVertex( int index, XYZ vertexPoint )
I create a wire using vertices extracted from a PolyCurve , and connect the wire to 2 devices.
All is well, except the 2 end vertices of the wire (first and last one) jump around when the wire is connected to a device so i have to manually drag them in place…which is bad…
SO, i KNOW the x,y,z coordinates of where I would like these end vertices to be: Start and End Point of the PolyCurve that generates the vertices for the wire when it is created.
So i feed this wire and new values for the Start and End vertices of the wire which are close the the Start and End point of the PolyCurve, by adding “1” to x and y (z i leave alone).
It is “working” in the sense that the end vertices are being moved, but they are moved very faaaaaaaaaaaaaaaar away from the x,y,z location of where they are supposed to be. (which again - is close to the Start and End point of the PolyCurve that generated the wire in the first place…)
Please, anyone, what am I doing wrong? Am I not using the same UCS??? Why is it working ok for setting the correct position of vertices when the wire is created but then interpreted so wrong when i want to reposition the end vertices of the wire???
And a picture of the result:
The Code, which for the most part i got from this forum:
*the IN to IN are …lists of 1 element… so that’s why i use  to get the only value from the list…
import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager clr.AddReference('System') from System.Collections.Generic import List import sys pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib' sys.path.append(pyt_path) clr.AddReference("RevitAPI") import Autodesk from Autodesk.Revit.DB import * clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.Elements) clr.ImportExtensions(Revit.GeometryConversion) clr.AddReference("RevitAPI") import Autodesk from Autodesk.Revit.DB.Electrical import * import System doc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application from System.Collections.Generic import * wire=UnwrapElement(IN) newStartX = IN #the above X value has 1 already added to it, then rounded newStartY = IN newStartZ = IN newEndX = IN #the above X value has 1 already added to it, then rounded newEndY = IN newEndZ = IN TransactionManager.Instance.EnsureInTransaction(doc) errorReport= try: #________# ASTA AR TREB SA MEARGA xyzStart = Autodesk.Revit.DB.XYZ(newStartX,newStartY,newStartZ) #wire.SetVertex(0, XYZ(0,0,0)) wire.SetVertex(0,xyzStart) #________# ASTA AR TREB SA MEARGA xyzEnd = Autodesk.Revit.DB.XYZ(newEndX,newEndY,newEndZ) lastvertIndex = wire.NumberOfVertices - 1 wire.SetVertex(lastvertIndex, xyzEnd) #wire.SetVertex(lastvertIndex, XYZ(newEndX,newEndY,newEndZ)) OUT = wire except: import traceback errorReport = traceback.format_exc() OUT = errorReport TransactionManager.Instance.TransactionTaskDone()
All help is greatly appreciated, this has been driving me crazy for the past week or so.