Hi everybody,
I have some probleme with this code :
I can’t create CropShape to view2 ?
here is the text of the sample:
Daniel OLIVES
Lyon-FRANCE
To obtain the outline that delimits one view and apply it to another, the Getcropshape method of the ViewcropregionshapeManager class is used.
Note: This method can return several line loops, which is why the first will have to be indexed.
view = unwraple (in [0])
View2 = Unwrapement (in [1])
TransactionManager. Instance.Sureintransaction (DOC)
loop = view.getcropregionshapeminaire (). Getcropshape () [0]
View2.Getcropregionshapemanager (). Setcropshape (Loop)
view2.cropboxactive = True
TransactionManager.Instance.TransActionTaskdone ()
In the event that we want to apply a discrepancy on the curve loop, it will be necessary to use the Createvia0ffset method. This will allow you to scroll through a vector.
This direction is calculated using the “normal” argument, which will correspond to the normal of the project and perpendicular to each of the loop lines.
UIUNIT = Doc.Getunits (Doc) .Getformatoptions (unittype.ut_length) .displayunits
Value = unitils.convertenternally (in [1], uiunit)
normal = xyz (0.0.1)
View_decalée = curveloop.createviaoffset (loop, value, normal)
Revit 2022: To convert units into the latest review versions, it will be necessary to define the variable “Ulunit” as follows:
UIUNIT = Doc.Getunits (). Getformatoptions (Spectypeid.length) .Getunittypeid ()
To reframe a view using a reference box, simply align the CROPBOX property of the viewboxxyz viewbox inserted outside the knot. If you want to collect existing boxes in the model, use Builtincategory OST_Volumeofinterest.
Note: It is important to activate the area framed by sight.
Box = Unwrapement (in [0]). Boundingbox [Doc.activeView]
view = doc.activeView
TransactionManager. Instance.Sureintransaction (DOC)
View.cropbox = Box
View.cropboxactive = True
View.cropboxvisible = True
TransactionManager. InstancetransActionTaskdone ()
1 Like
@daniel82KGE ,
i cleaned up your code - syntex - but is still not working, what do want to do?
import clr
import sys
import System
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
view = UnwrapElement(IN[0])
View2 = UnwrapElement(IN[1])
TransactionManager. Instance.Sureintransaction (doc)
loop = view.getcropregionshapeminaire().Getcropshape()[0]
View2.Getcropregionshapemanager().Setcropshape(Loop)
view2.cropboxactive = True
TransactionManager.Instance.TransActionTaskdone()
#In the event that we want to apply a discrepancy on the curve loop, it will be necessary to use the Createvia0ffset method. This will allow you to scroll through a vector.
#This direction is calculated using the “normal” argument, which will correspond to the normal of the project and perpendicular to each of the loop lines.
UIUNIT = doc.Getunits(doc).Getformatoptions(unittype.ut_length).displayunits
Value = unitils.convertenternally(IN[1],uiunit)
normal = xyz(0,0,1)
View_decalée = curveloop.createviaoffset(loop,value,normal)
#Revit 2022: To convert units into the latest review versions, it will be necessary to define the variable “Ulunit” as follows:
UIUNIT = doc.Getunits().Getformatoptions(Spectypeid.length).Getunittypeid()
#To reframe a view using a reference box, simply align the CROPBOX property of the viewboxxyz viewbox inserted outside the knot. If you want to collect existing boxes in the model, use Builtincategory OST_Volumeofinterest.
#Note: It is important to activate the area framed by sight.
Box = Unwrapement (IN[0]).Boundingbox[doc.activeView]
view = doc.activeView
TransactionManager.Instance.Sureintransaction(doc)
View.cropbox = Box
View.cropboxactive = True
View.cropboxvisible = True
TransactionManager.InstancetransActionTaskdone()
OUT = "Done"
Hi here is the correct code (sorry google translate make bad correction)
The code copie from view the CropShape to view2
It’s ok now
I try now to decale with :
vue_décalée = CurveLoop.CreateViaOffset(loop, valeur, normal)
Daniel
import clr
import sys
import System
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
view = UnwrapElement(IN[0])
View2 = UnwrapElement(IN[1])
TransactionManager.Instance.EnsureInTransaction(doc)
loop = view.GetCropRegionShapeManager().GetCropShape()[0]
View2.GetCropRegionShapeManager().SetCropShape(loop)
View2.CropBoxActive = True
OUT = "Done"
1 Like
You need to close your transaction. See last line befor out.
2 Likes
Hi,
I now can resize my cropshape with decale
It’s ok for me
Danie