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!
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 -
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.
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 wrote:
just crashed my C3D so it's even not repairable/reinstallable.
I hope not due to my code!
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 -
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
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)?
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.
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.
To toggle the Automatic Rebuild option for surfaces:
SettingsSurface settingsSurface = CivilDocument.Settings.GetSettings<SettingsSurface>();
if (!settingsSurface.Defaults.AutoRebuild.Value)
{
settingsSurface.Defaults.AutoRebuild.Value = true;
}
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.
I think you are facing issue with surf.Rebuild()
Verify this setting:
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.
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
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)