Modify outside of transaction ERROR

Trying to move a section box up 1’ and im getting this error and i dont know why…

Yeah that was the issue I had when solving the move scope box issue. Try using the Python code here:

Do you have any idea what could be wrong with this section box?

No idea, but best to keep that discussion over there - otherwise things get confused.

1 Like

Any reason why your python script would generate a "’ error?

code.py (844 Bytes)

import clr
from System.Collections.Generic
import*
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import*
import Autodesk

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence
import DocumentManager
from RevitServices.Transactions
import TransactionManager

doc= DocumentManager.Instance.CurrentDBDocument
items={UnwrapElement(IN[0])}
xyz = UnwrapElement(IN[1]).ToXyz()

ids = list()
for item in items:
ids.append(item.Id)

itemlist = List [ElementId] (ids)

TransactionManager.Instance.EnsureInTransaction(doc)

moveditems = ElementTransformUtils.MoveElements(doc,itemlist,xyz)

TransactionManager.Instance.TransactionTaskDone()

OUT = items

Looks like line there was an accidental carriage return on line 3. Line 2 should instead be from System.Collections.Generic import * and remove the import * on its own line.

I’m still receiving the same error: What did I miss?

import clr
from System.Collections.Generic import *
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
import Autodesk

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence
import DocumentManager
from RevitServices.Transactions
import TransactionManager

doc= DocumentManager.Instance.CurrentDBDocument
items={UnwrapElement(IN[0])}
xyz = UnwrapElement(IN[1]).ToXyz()

ids = list()
for item in items:
ids.append(item.Id)

itemlist = List [ElementId] (ids)

TransactionManager.Instance.EnsureInTransaction(doc)

moveditems = ElementTransformUtils.MoveElements(doc,itemlist,xyz)

TransactionManager.Instance.TransactionTaskDone()

OUT = items

Cody,

I am not seeing the need for Import Autodesk on Line 5

Also, I have typically kept the import DocumentManager and import TransactionManager on the line above each.
so line 15 would be at the end of line 14 and line 17 would be at the end of line 16 with a space between.

I haven’t tested. Hope it works.

1 Like

Likewise, there is no need to import RevitServices directly on line 14

I’m not following.

Mark is noting that the import statements should be on the same line as from RevitServices.xxxx, i.e. from RevitServices.Persistence import DocumentManager is a single line. The same should be done for TransactionManager. I’m just adding that the line import RevitServices isn’t necessary for the code to work either.

1 Like