Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Surface .NET API & Rebuild

14 REPLIES 14
Reply
Message 1 of 15
Jeff_M
1187 Views, 14 Replies

Surface .NET API & Rebuild

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
14 REPLIES 14
Message 2 of 15
Alfred.NESWADBA
in reply to: Jeff_M

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 15
Jeff_M
in reply to: Alfred.NESWADBA

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
Message 4 of 15
Alfred.NESWADBA
in reply to: Jeff_M

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 15
Jeff_M
in reply to: Alfred.NESWADBA


@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
Message 6 of 15
Alfred.NESWADBA
in reply to: Jeff_M

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 7 of 15

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



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 8 of 15
RasmusB
in reply to: Jeff_M

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)?

---
2B or not 2B? That is the question! The answer is FF.
Message 9 of 15
osvaldast
in reply to: Jeff_M

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

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
Message 11 of 15
varshaauti27
in reply to: Jeff_M

To toggle the Automatic Rebuild option for surfaces:

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

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
Message 13 of 15

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.

 

Message 14 of 15

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

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)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report