The pipe inline orientation can be accessed using XAxis and ZAxis properties. From the help file, we can read:
- xAxis: Input vector (in WCS) to be used to define the new plane that will contain the inline asset
- zAxis: Input X-Direction vector (WCS) for the inline asset
And, as the properties are read-only, we can change them using the SetOrientation method.
Despite the explanation, a graphical visualization can help we understand the properties. After writing a small piece of code to change the properties, we can see the following:
XAxis: change the asset orientation regarding the flow on the pipe line, as shown on the image below.
ZAxis: rotate the asset along the pipe line axis, helping place it properly, as shown below.
<p>If you need to change any of those directions, then notice that the vectors are unit vectors. Below is a sample code that changes both X and Z directions (just invert the values).</p> <pre class="line-numbers"><code>[CommandMethod("assetOrient")] public void CmdAssetOrientation() { Editor ed = Application.DocumentManager. MdiActiveDocument.Editor; PromptEntityOptions peo = new PromptEntityOptions("Select inline asset"); peo.SetRejectMessage("Only inline asset"); peo.AddAllowedClass(typeof(PipeInlineAsset), true); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) return; Database db = Application.DocumentManager. MdiActiveDocument.Database; using (Transaction trans = db.TransactionManager.StartTransaction()) { PipeInlineAsset pipeAsset = trans.GetObject(per.ObjectId, OpenMode.ForWrite) as PipeInlineAsset; // get current values Point3d position = pipeAsset.Position; Vector3d xDir = pipeAsset.XAxis; Vector3d zDir = pipeAsset.ZAxis; // change the direction the asset is comparing to the line // for instance, a valve will change rotate along the line Vector3d zDirInverted = zDir.Negate(); // change the orientation of the asset // for instace, a valve will change the in/out of the flow Vector3d xDirInverted = xDir.Negate(); // apply the new value pipeAsset.SetOrientation(xDirInverted, zDirInverted); trans.Commit(); } }</code></pre>

Leave a Reply