Revert to original layers properties Using .net

Revert to original layers properties Using .net

kmkxperia
Advocate Advocate
514 Views
6 Replies
Message 1 of 7

Revert to original layers properties Using .net

kmkxperia
Advocate
Advocate

HI,

In the Auto cad Layers I want to check the Properties that are eing modified and check its original/Default Value and new value.. The reason is to take the decision to revert to original values of change Layers with new values.

how we can achieve this using C#.net. and can it e extended to other ojets in Autocad.

 

 Thanks

0 Likes
515 Views
6 Replies
Replies (6)
Message 2 of 7

norman.yuan
Mentor
Mentor

You need to have the original properties saved before you can revert them back. That is where the LayerStateManager class comes into play: look into its SaveLayerState/GetLayerState/RestoreLayerState() methods.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 7

kmkxperia
Advocate
Advocate

Ok..

Now if I am editing some layers but not saved, so before saving 

Now I want to list all of  the layers which I was modifying .

Say I have 10 layers in drawing

Now I was modifying 3 and 4, 5 layers now I haven't yed saved the drawing.. but before that I want to check which all layers were being modified..

So it should list 3,4,5 layers list..

 

0 Likes
Message 4 of 7

ActivistInvestor
Mentor
Mentor

You could use an ObjectOverrule to track changes to layers as they happen.

 

But, whether that is a good way to do it depends on whether you want to prevent the changes from happening in the first place or, want to allow the layers to be changed, but not saved with the drawing.

 

When you ask for help, it's it's easier for others to help you, if you try to express your overall problem and intention rather than asking how to go about solving a very specific problem.

0 Likes
Message 5 of 7

norman.yuan
Mentor
Mentor
Since you are posting in programming forum, so I assume that when you say "Now I am modifying 3 and 4, 5 layers...", it means your code does the modifying. Therefore, if your program expects to revert the layer changes in certain conditions, you need to write the code to save current layer states PRIOR TO proceeding the modification. That is, if your code makes changes and you want to be able to go back, you need to save the original state. Since you are talking layer changes, LayerStateManager is specific designed for that purpose.

Or, you can rely on AutoCAD's built-in UNDO mechanism

Norman Yuan

Drive CAD With Code

EESignature

Message 6 of 7

kmkxperia
Advocate
Advocate

ok this is what I want to check.. 
I have 6 Layers which I get the details from the layers code. now suppose If I modify Say Layer 4 Color to 'Red'
So its original color was white and now its changed to Red..
Now when click on utton  I should e ale to see the all the modified layers and when I click on each layer in the list it dsiplays the Modified properties and its original value and modified one..

Hope I was ale to put my prolem correctly.
Thanks,

kmkxperia_0-1707240997379.png

 

 

0 Likes
Message 7 of 7

ActivistInvestor
Mentor
Mentor

So, you don't want to prevent the change from happening, you only want to know that it happened, and specifically what the changes were (e.g., what layer properties were changed, and what the old and new values are)? Does this extend to Viewport layer property overrides, and if so, does that include viewport-frozen layers (if the answer to all of these questions is 'yes', the problem becomes a bit more complicated to solve, as viewport-frozen layers are stored in viewports, while other viewport layer property overrides are stored in the layer).

 

Is there some data synchronization that must happen as a result of changing layer properties?

0 Likes