Surface .NET API & Rebuild

Surface .NET API & Rebuild

Jeff_M
Consultant Consultant
1,874 Views
14 Replies
Message 1 of 15

Surface .NET API & Rebuild

Jeff_M
Consultant
Consultant

I have some code that edits the breaklines of a surface. Everything works correctly, except for the surface rebuild when finished.

 

At the end of the command I use:

 

surf.Rebuild();

 

But when the command completes I still need to manually rebuild the surface to see the result of my command's edits. This is in both 2013 & 2014. I shouldn't need to do this and was just wondering why the Rebuild() method doesn't always work.

 

Also, is it possible to toggle the Automatic Rebuild option for surfaces in code? I haven't been able to find anything on this.

 

Thanks!

Jeff_M, also a frequent Swamper
EESignature
0 Likes
1,875 Views
14 Replies
Replies (14)
Message 2 of 15

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

have you commited the modification of the breaklines before you started surf.Rebuild?

In my code I have not modified breaklines, but add some based on polylines (LW-Polylines and 3D-Polylines), after that I do a surf.Update and then surf.Rebuild (all based in COM-objects as it seems to be more stable). That works in 2012/2013/2014 without any problems (just changed the references).

 

If you have a short code that makes it easier to try to reproduce your issue, I'll try it.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 15

Jeff_M
Consultant
Consultant

Thanks, Alfred. I've had no stability issues using the .NET API's. This is actually a conversion of existing code (which was ported from old VBA code), which used COM, to strictly use the managed wrappers. I've attached the complete solution. I'm sure it could be streamlined a bit, but my time is limited right now so I was more interested in getting a working version posted than optimizing it. At some point I will reduce the number of Transactions, but I don't think they are affecting the outcome.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 4 of 15

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

sorry to not have a quick solution to the surface-rebuild problem, I tried it, I could reproduce it and .... just crashed my C3D so it's even not repairable/reinstallable. So at the moment I'm starting a process of uninstall some stuff to get 2013 installed again and working. Sorry for now!

 

>> Also, is it possible to toggle the Automatic Rebuild option for surfaces in code?

Never found that yet.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 15

Jeff_M
Consultant
Consultant

@Alfred.NESWADBA wrote:

 

 just crashed my C3D so it's even not repairable/reinstallable.


I hope not due to my code!

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 6 of 15

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> I hope not due to my code!

No, I don't think so.

Anything removed files like base.dcl, acad.pat from the users-SUPPORT and from the UserDataCache folder, each for Civil3D 2013. I have no idea how that was done or what did this. It's some days ago I started C3D2013, it was just your code that was prepared for 2013 and so I recognized it now.

 

BTW: I have got it repaired by removing the SUPPORT folder and the de-DE folder (for english versions it's the en-US folder) from the UserDataCache directory, then I did a repair install. This did recreate the files for these folders, then I only had to copy the files to my user folder into the SUPPORT-directory. So it looks ok for now ...bat then it was quite late to do any more tests).

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 15

Anonymous
Not applicable

is it possible to toggle the Automatic Rebuild option for surfaces in code?

 

>>> Looks like this is not exposed for Surface object.

 

I find 'Automatic Rebuild' option is exposed for Corridor object through - property public bool RebuildAutomatic { get; set; } of corridor

 

I am logging a wish list to expose API to toggle the Automatic Rebuild option for surface.

 

Thanks,

Partha

ADN

0 Likes
Message 8 of 15

Anonymous
Not applicable

Without having looked at your code: Have you tried to run your code without calling Rebuild? Is it then sufficient to call Rebuild once on your surface through the GUI to keep it up to date? Or does the first call to Rebuild affect any other objects in such a way that the surface on which you call Rebuild is kept out of date yet another time (until you call Rebuild again)?

0 Likes
Message 9 of 15

Anonymous
Not applicable

Hi,

You have to commit all your changes to breaklines first. When, in next transaction, open surface for read and rebuild it. Hope this helps.

Message 10 of 15

Civil3DReminders_com
Mentor
Mentor

So sad, 11 years later and Autodesk still sucks at supporting an API. The Rebuild() method on a surface doesn't Rebuild a surface in Civil 3D 2024 and a user needs to manually do it. 

 

 

Horrible customer service. 

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
0 Likes
Message 11 of 15

varshaauti27
Advocate
Advocate

To toggle the Automatic Rebuild option for surfaces:

SettingsSurface settingsSurface = CivilDocument.Settings.GetSettings<SettingsSurface>();
if (!settingsSurface.Defaults.AutoRebuild.Value)
{
settingsSurface.Defaults.AutoRebuild.Value = true;
}
0 Likes
Message 12 of 15

Civil3DReminders_com
Mentor
Mentor

I haven't tested this, but I don't think this addresses the issue. I believe this just sets the default state of the Surface rebuild when the surface is created. Once the surface has been created, it doesn't toggle the AutoRebuild value of the TinSurface. 

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
0 Likes
Message 13 of 15

varshaauti27
Advocate
Advocate

I think you are facing issue with surf.Rebuild()

 

Verify this setting:

varshaauti27_0-1709574530758.png

If this is set to "No", Surf.Rebuild() won't work as expected and you have to manually rebuild surface.

 

So before executing Surf.Rebuild() you can set AutoRebuild value to 'true' and once you are done with rebuild you can reset it to original value. It did work for me.

 

0 Likes
Message 14 of 15

Civil3DReminders_com
Mentor
Mentor

It appears the AutoRebuild Property was added to a Surface object in Civil 3D 2022.
https://help.autodesk.com/view/CIV3D/2022/ENU/?guid=378310d0-b2de-b4d9-467e-a09e1818e1d9

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
Message 15 of 15

jklinkeB8EEG
Contributor
Contributor

Just my two cents but for some reason after I rebuild the surface a quick RegenALL seems to show me an updated surface after I have committed the transaction.

 

tr.Commit()
surf.Rebuild()
doc.SendStringToExecute("regenall" & vbCrLf, True, False, True)

0 Likes