cart: empty [ Login ]

Drawing on UCS

1 
McGum
1/21/2019 3:45 PM
HI Wout, I have created a UCS, added this to the collection an try to draw relatet to this UCS. How can I do this? I tryed this:
C# Code:
modelContext.UcsCollection.Add(new DxfUcs(instanceHolder.Title, new Point3D(0, 0, 0), new Vector3D(1, 0, 0), Vector3D.YAxis.RotateX(instanceHolder.AngleRad))); model.ModelLayout.Ucs = model.UcsCollection[instanceHolder.Title]; var line = new DxfPolyline2D(WWHelpers.CreateFrom(Color.Gray), GeometricObject) { Closed = true, Layer = model.Layers[CADLayerStrings.StrRoofing], }; model.ModelLayout.Entities.Add(line);
But it dosnt work :(
Wout
1/24/2019 3:40 PM
Hi, Here's how you set an UCS for model space. Note that it doesn't affect the entities in any way, it just affects the AutoCAD user interface.
C# Code:
using System; using System.Collections.Generic; using WW.Cad.IO; using WW.Cad.Model; using WW.Cad.Model.Tables; using WW.Math; namespace ConsoleApplication { public static class UcsTest { public static void Test() { DxfModel model = new DxfModel(); double angle = 30d * WW.Math.Constants.DegreesToRadians; Matrix4D m = Transformation4D.RotateZ(angle); DxfUcs ucs = new DxfUcs(string.Empty, Point3D.Zero, m.Transform(Vector3D.XAxis), m.Transform(Vector3D.YAxis)); model.Header.Ucs = ucs; DxfVPort vport = model.VPorts.GetActiveVPort(); if (vport == null) { vport = DxfVPort.CreateActiveVPort(); model.VPorts.Add(vport); } vport.Ucs = new DxfUcs(string.Empty, Point3D.Zero, m.Transform(Vector3D.XAxis), m.Transform(Vector3D.YAxis)); DwgWriter.Write(@"D:\support\ucstest.dwg", model); } } }
- Wout
McGum
1/24/2019 3:49 PM
Hi Wout, thanks. But if the UCS has no affect to the entites, then I have no effort :( Can you implement this, that if the current UCS is set, the entity will transform correct? Or is there a hook (on Entity insert or so..)
Wout
1/24/2019 3:53 PM
Hi, If you want to transform the entity, then you should call method DxfEntity.TransformMe() with a transformation matrix. The documentation has an example. - Wout
Wout
1/24/2019 3:55 PM
Maybe you just want a rotated viewport though, in general I wouldn't rotate the entities themselves for presentation purposes. - Wout
McGum
1/24/2019 4:01 PM
I now ... at the moment we are using the TransformMe() .. but - it looks easer to use a UCS (even in 3D .. ). But found the Event Adding and Added .. so I can draw flat on the the ModelLayout and transform on Added (or Adding) Will think abaout if this is a good option :)
McGum
1/24/2019 4:02 PM
No, viewport isn't the solution ..
1