Need to create callouts with Python Script

I feel i’m close to create callouts using python script, but i don’t know what is the problem of this code if somebody can help.
And i know that Archi-lab is having a ready node which does the same, but i need to get this function with a python script

thanks in advance

import clr
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

calloutType = IN[0]
calloutViewFamilyType = IN[1]
view = IN[2]


# Create the callout view
calloutView = ViewCallout.Create(doc, calloutType.Id, calloutViewFamilyType.Id, view.Id, XYZ(0, 0, 0))


OUT = calloutView

but it gives this error

There is no ViewCallout class in the Revit API, that’s why you get that warning.

You can see how archi-lab creates a callout, it’s open source, it’s on line 308 in Views.cs: archilab/Views.cs at c491616c674d46cb254bd2a68184a34b4148a802 · ksobon/archilab · GitHub

It’s not hard to translate from C# to python, a lot of things are really similar.

So you should use something like this:

# Create the callout view
calloutView = ViewSection.CreateCallout(doc, view.Id, calloutViewFamilyType.Id, pt1, pt2);

(I haven’t tested this, you also need two points, so it’s not just a simple replacement.)

API docs for this method can be found here: CreateCallout Method

1 Like

@faramawy any chance your original code was written by chat gpt? qondering as that is the only way I have seen classes created in this way.