There is an archived thread with code that does not work as posted. It does create a sheet but has many caveats.
Here is my version:
Sub createNewSheet(newModelName As String, newModelDescription As String)'variables for new sheet model in memory Dim oSheet As SheetDefinition Dim oModel As ModelReference 'both types must have default info to start with in order to update their settings Set oSheet = ActiveModelReference.GetSheetDefinition Set oModel = ActiveDesignFile.DefaultModelReference 'Add any specific settings you want for your sheet and model here With oSheet .Origin.x = 0# .Origin.Y = 0# .Width = oModel.WorkingUnitsToDouble("11'") * oModel.UORsPerMasterUnit .Height = oModel.WorkingUnitsToDouble("8.5'") * oModel.UORsPerMasterUnit ' .Rotation = 0# .Rotation = Radians(90#) End With With oModel If .Type <> msdModelTypeSheet Then .Type = msdModelTypeSheet .SetSheetDefinition oSheet End With 'Call this command to create the new sheet in the file ActiveDesignFile.Models.Add oModel, newModelName, newModelDescription, msdModelTypeSheet, False ActiveDesignFile.Models(ActiveDesignFile.Models.Count).ActivateEnd Sub
So here is what does not work still:
The code to define the origin - .origin.x =0 .origin.y=0
The origin remains the same as the active model when the new model was created in memory. Apparently, this code copies many of the active model properties when it creates the new model. I had to test if the new model was a sheet before attempting to set its type to msdModelTypeSheet. The original code for width and height used simply the two numbers. I found I had to use all of that extra code to get those to the correct size.
So my questions are:
I found that it appears to create the sheet model from the default model - which apparently is a good reason to not make the default model a sheet, as my code is constantly shifting the sheet definition origin of the default model - even though I cannot see where in the code it is occurring.
But I figured out that by activating the new sheet after it is created, I can reset the sheet to 0,0 and then I can move it from there to wherever I want.
Charles (Chuck) Rheault CADD Manager
MDOT State Highway Administration
Answer Verified By: caddcop
Hi Chuck. I have same issue with an existing sheet that was created with wrong origin X,Ys and I want to set it to 0,0.
I stuck at on 'activating the sheet' that you suggested. Please share the code on how to activate sheet and set the origin to 0,0
Thanks
Hi Satya,
it is recommended to do not reopen answered discussions. This one is 8 years old, so it's probably about different version than you use.
Please ask in a new post, where you can link this one as a reference, where similar topic was discussed. Also, please read and follow the forum best practices and to share information what product and what version you use.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point