PDA

View Full Version : Accessing Views using the API


GuyR
2005-09-06, 12:11 PM
I'm trying to access and set view parameters. For example changing sheet titles. However when I select a view by name(elem.Name) and try and get it's category(elem.category.Name) I get a category None and also no parameter set.

Are there some elements that we can't access with the current version of the API?

Guy

FK
2005-09-06, 06:09 PM
My hunch is that you are getting something wrong when you are doing the lookup by name. There are auxiliary elements that are just not interesting.

If you select the view in the project browser, you should get the right element passed in. I hope. ;-)

GuyR
2005-09-06, 09:02 PM
Thanks Fedor,

If you select anything in the project browser the external tools menu is greyed out. I'll have a look at the auxillary elements issue. That sounds like it might be the problem. If I'm not selecting the view what am I selecting ;-)

Guy

FK
2005-09-07, 04:16 AM
Hmmm...

One kind of an auxiliary element is the elevation/section label.

How many elements do you get if you run a substring match through them all?

GuyR
2005-09-07, 07:30 AM
Cheers Fedor,

See attached text output of this code:

fo = file("c:/pyRevit/test.txt","w")
for elem in allElements:
if elem.Name == "Floor Plan: Level 1" or elem.Name == "Level 1":
try:
cat = elem.Category.Name
except:
cat = "no category"
tat = elem.GetType()
fo.write("%s, %s, %s \n" %(elem.Name, cat, tat))
if elem.Parameters != None:
for param in elem.Parameters:
fo.write(" parameter = " + param.Definition.Name+"\n")
else:
fo.write(" No parameters for this element \n")
fo.write("\n\n\n")
fo.close()
winForms.MessageBox.Show("finished")

Still trying to disgest why level1 gets listed 4 times. I can explain 2 of them (plan + plan on the sheet). I'll see if I can work out a way to list what each element is. Interestingly 'Floor Plan : Level 1' has no parameters so not sure what that refers to....

Will keep experimenting.

Guy

ps: The goal is setting text in annotation elements based on the sheet number of the view. Ideally it would be great if there was either a sheet parameter or we could get the view parameters of a detail/annotation instance. In my case I'm just running the API command for each view.

FK
2005-09-07, 06:24 PM
How about level labels on elevations?

GuyR
2005-09-07, 11:16 PM
Cheers Fedor, that'll be it.

Does anyone know if there is a way to find out what an element refers to when there isn't an associated category?

Guy