@madhukum339
It looks to me, your code is problematic: the class level variable "plot" is initialized as "false", and never changed, thus, the last 2 lines of code in the command method:
if (plot)
PublishModelSpaceToPdf()
is never executed.
However, your have the save 2 lines of code in the ProcessDimensions() method, and inside of it, you have a local variable "plot", which can be set to true, thus the plotting may get proceeded within the ProcessDimensions() method.
If executing built-in command "DIMREGEN" is the intention to update the dimensions in the dynamic block BEFORE plotting (I am not sure if it works without trying it myself), then it is obviously has no effect as you wished.
So, you need to fix your code like this:
1. Remove last a 2 or 3 lines of code from the ProcessDimensions(). That is, do not do the plotting inside the ProcessDimensions() method;
2. Let ProcessDimentions() return true/false; that is, when the dynamic block(s) with dimension is/are updated, the method would return true, meaning plotting is needed after the dimensions are processed.
3. If "DIMREGEN" indeed fix the dimension's offset in the dynamic plot, you DO NOT call in with SendStringToExecute(), because it would not be executed BEFORE your command method finishes. You can try Editor.Command("DIMREGEN") instead.
4. You need to get system variable "BACKGROUNDPLOT" to 0, not 3!
Also, I'd not recommend post code as picture, or as attachment (unless there is huge number of lines of code), it makes commenting your code rather difficult: I have constantly/repeatedly leave the comment text window and open the attached code file/picture to look at the code, and then close it and go back to the comment window to continue. Use the "</>" button to copy/paste code, so that the code can be browsed while commenting by simply scrolling the web page. Much easier.