Hy,
I want to create a Plugin which do create Drawings (from DrawingTab) automatically like:
1: Load Drawing template
2: Load different views from current opened Layout
3: Define position of views
4: Save a dxf and a PDF
But I can’t find the API for this…
Thx & Regards
Feature
1 Like
TSy
August 17, 2023, 8:50am
2
Drawings are mostly UI side stuff, so I think you’ll need to look into UX.Shared, and UX.Shared.Infrastructure dlls.
There are some basics like IDrawingContext, and then a bunch of commands that are available to import as IActionItems
1 Like
idkfa
August 18, 2023, 4:04pm
3
Tried it out, it should be possible, but haven’t figure out how to create pdf and dwg automatically.
IApplication app;
IDrawingViewGenerationAction projectAction;
IImportDrawingTemplateAction templateAction;
ICommandRegistry registry;
public override void Execute()
{
templateAction.StartAction();
var a0 = PathUtility.BaseDirectory + "SrcTemplates\\Drawings\\DrawingTemplateA0.vcm";
foreach (var item in templateAction.ActionProperties)
{
if (item.Name == "File")
{
item.Value = a0;
}
}
templateAction.ApplyAction();
var minCorner = app.DrawingWorld.BoundBox.MinCorner;
var maxCorner = app.DrawingWorld.BoundBox.MaxCorner;
var intervalX = (maxCorner.X - minCorner.X) * 0.8 / 3.0;
var intervalY = (maxCorner.Y - minCorner.Y) * 0.8 / 2.0;
var borderX = (maxCorner.X - minCorner.X) * 0.15;
var borderY = (maxCorner.Y - minCorner.Y) * 0.3;
// Top
projectAction.CreateView(DrawingViewPoints.Top);
var top = (IDrawingView)app.DrawingWorld.LayoutItems.Last();
top.Scale = "1:3";
var topMatrix = new Matrix();
topMatrix.Px = minCorner.X + borderX + intervalX * 0;
topMatrix.Py = minCorner.Y + borderY + intervalY;
top.TransformationInWorld = topMatrix;
// Left
projectAction.CreateView(DrawingViewPoints.Left);
var left = (IDrawingView)app.DrawingWorld.LayoutItems.Last();
left.Scale = "1:3";
var leftMatrix = new Matrix();
leftMatrix.Px = minCorner.X + borderX + intervalX * 1;
leftMatrix.Py = minCorner.Y + borderY + intervalY;
left.TransformationInWorld = leftMatrix;
// Front
projectAction.CreateView(DrawingViewPoints.Front);
var front = (IDrawingView)app.DrawingWorld.LayoutItems.Last();
front.Scale = "1:3";
var frontMatrix = new Matrix();
frontMatrix.Px = minCorner.X + borderX + intervalX * 2;
frontMatrix.Py = minCorner.Y + borderY + intervalY;
front.TransformationInWorld = frontMatrix;
// Bottom
projectAction.CreateView(DrawingViewPoints.Down);
var bottom = (IDrawingView)app.DrawingWorld.LayoutItems.Last();
bottom.Scale = "1:3";
var bottomMatrix = new Matrix();
bottomMatrix.Px = minCorner.X + borderX + intervalX * 0;
bottomMatrix.Py = minCorner.Y + borderY;
bottom.TransformationInWorld = bottomMatrix;
// Right
projectAction.CreateView(DrawingViewPoints.Right);
var right = (IDrawingView)app.DrawingWorld.LayoutItems.Last();
right.Scale = "1:3";
var rightMatrix = new Matrix();
rightMatrix.Px = minCorner.X + borderX + intervalX * 1;
rightMatrix.Py = minCorner.Y + borderY;
right.TransformationInWorld = rightMatrix;
// Back
projectAction.CreateView(DrawingViewPoints.Back);
var back = (IDrawingView)app.DrawingWorld.LayoutItems.Last();
back.Scale = "1:3";
var backMatrix = new Matrix();
backMatrix.Px = minCorner.X + borderX + intervalX * 2;
backMatrix.Py = minCorner.Y + borderY;
back.TransformationInWorld = backMatrix;
registry.ExecuteAction("ExportToVectorDrawing2D", true, true);
}
3 Likes
@idkfa Thank you!
@TSy any idea for the saving stuff as dxf and pdf?
Hy,
is there somewhere a list with all possible commands like:
Thx & Regards
Feature
TSy
August 21, 2023, 9:05am
6
You can get all registered actions from ICommandRegistry.Actions and then get the IActionItem.Id from each.
1 Like
Hy @TSy or everyone who can help,
how to select pdf or dxf and trigger export?
Regards
Feature
TSy
August 21, 2023, 12:03pm
8
Try casting the IActionItem with id “ExportToVectorDrawing2D” to IExportToVectorDrawingCommand and then using the ApplyAction method from that interface.
Hy @TSy ,
I really would try this but my VC 4.7 Premium does not know these interface!?
but it should be public:
Thx & Regards
Feature
TSy
August 21, 2023, 12:46pm
10
You need to add reference to the UX.Shared.Infrastructure dll. Notice how the help page says
Assembly: UX.Shared.Infrastructure
2 Likes
Hy again,
and is there a way to get the dialogService which opens after successfully realize your magic, for finally save the file by keeping the full automatic? → No user interaction…
The help is helping not so much:
Thx & Regards
Feature
Hy,
it looks like nobody from VC -Stuff has ever thought about that some people would automate that drawing stuff…
The method “GetSupportedFormats” sometime throw nullReferenceException.
In Helpfile alot of important stuff is missing
How should I get the FileSaveDialog instead of show it to user?
Why is that so that a lot of VC Framework is awesome and some parts are so tedious!?
Feature
1 Like
TSy
August 22, 2023, 5:48am
13
I’d say that really only the Create3d.Shared is the real public .NET API of VC. Everything else is a bit hit or miss.
Why there is no proper API for automating drawing generation and saving? Probably they just haven’t got enough requests for such use case from customers at VC’s support and sales.
Hy @TSy ,
that’s really bad news, we try to implement VC in our company in different departments and I have to check the technical feasibility… → So this project fail at the last step by checking the first point, cause of missing API!
But I will thank you and @idkfa , for getting me fast to this ugly limitation!
VC will probably miss some license sales because of this!
Regards
Feature
1 Like
TSy
August 22, 2023, 7:28am
15
Please contact VC technical support. They might figure out some workaround for you.
idkfa:
(post deleted by author)
I have read it, may support will me also offer the working api…
Regards
Feature
1 Like
Hy @idkfa ,
my last open point (without the missing possibilty to save… ) is to create one isometric view like (I do it manual):
For this I first set vcCamera to the the view i I need (works), and use a bit modified code from you, but VC wont take over this… → May you have an idea for this?
Thx & Regards
Feature
idkfa
August 22, 2023, 2:26pm
20
It seems that DrawingViewPoints.Current is not working, recommend to contact support.
Ok, I will add this also to my official request…
Thx & Regards
Feature