C# help

I’m having trouble with this C# code

My code reads an excel document and creates a bunch of sheets in Revit.
I thought it’d be useful to add a check to make sure they have our official company title blocks in their project… But I can’t get it to work!
The sheet DOES exist… but I get the error each time. Any idea why?

Also, @jacob.small - any news on a C# section?

Looked it over and decided that until Sol is back we’ll keep stuff related to C# development in the Developers category. Utilize the tags for CSharp, Zero Touch, Node Model, etc. as applicable.

Went ahead and added CSharp and ZeoTouch for you so this can be an example. :slight_smile:

2 Likes

For your actual question, does the code compile? When do you debug do you get any errors?

You might want to attend the Office hour starting in… 45 minutes or so. Speaking of which, I need to finish my prep work. :rofl:

compiles fine, shows up in Revit…

But when I click on it in Revit I get the titleblock error… Suggesting I don’t have those title blocks.

I tried putting in the family and type name, that didn’t work.
I tried swearing at it, that didn’t work.
I assume I maybe have to loop through the titleblocks instead?

Ah! so this is a full add-in, not a zero touch node?

Yep

*scratching his head *

Where in the Revit API did you get the GetTitleBlockByName method?

Ah sorry, posted this all in a rush. Forgot what I’d actually done (wrote it a while ago, got frustrated and gave up :frowning: )

aaand I just realised my error…

I needed to specify the type name not the family name. Doh!

image

Changed to A1 Landscape and it works.
Amazing how just saying stuff ‘out loud’ can be so helpful :rofl:

But actually I want the family name not the type name… so have to work out how to tweak that now. But that’s Monday’s problem cos I’m on leave today. Whoooo.

1 Like

It’s called the rubber duck test. Put a rubber duck (or similar small friend) on your desk. When you get stuck and can’t figure out why, ask them for an assist. Then explain every. Single. Line. In. Your. Code. To. Them. Out loud.

You’ll be shocked how often they find the issue.

8 Likes

OK, Bob the duck just got promoted.

image

9 Likes

Good old Bob

1 Like

Need to buy a rubber duck :smiley: :duck:

My current duck is actually a winged horse named Frank.

He hates the Robot API, and tends to swear a lot when I have projects open with Robot references.

7 Likes

Bob is from Liverpool in England so has a strong scouse accent. He’s really rude and swears a lot too.
Tbh, I’m not sure how much help he’s gunna be unless I find him some worms to eat…

#Anthropomorphization4AECProfessionals. :rofl:

1 Like

Mine (small friend) always sticks out his tongue :grin:

4 Likes

Try this:

Is that to get the family name?

No, this returns the tBlock as Element

I don’t understand what that means.

My issue before was I was feeding it the family name and it wanted type name. It now works fine with the type name.

I’d like to specify the family name instead but I can’t work out how to do that.

I will send you an example today :slight_smile:

1 Like