Hello,
I am creating a pressure pipe network using .net.
I would like to know how I can get the PressurePartSize to be able to use in the
public ObjectId AddLinePipe method (LineSegment3d line, PressurePartSize partSize);
I know the classes are defined as Internal, does anyone know any method of getting access to the class?
something like this https://forums.autodesk.com/t5/civil-3d-customization/how-to-access-pressure-network-parts-lists-usi...
I tried to adapt the function to return PressurePartSize instead of PressurePartsLists but I couldn't
Can someone help me?
thanks
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
Solved by benkas. Go to Solution.
Solved by Jeff_M. Go to Solution.
I have not done much with the PressurePipes, but this works to get the desired pipe. If you know the GUID for the part you could just use the partslist.GetPart(guid) method instead of looping through the list.
using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
{
//this is the extension method I have previosuly posted to this forum
var partslists = civdoc.Styles.GetPressurePartListsExt();
var partslist = (PressurePartList)tr.GetObject(partslists[0], OpenMode.ForRead);
var parts = partslist.GetParts(PressurePartDomainType.Pipe);
PressurePartSize useThisPart = null;
foreach (PressurePartSize part in parts)
{
//things that make you hmmmm.... why does the DiameterNominal return a string in the format shown insted of a double?
var size = part.GetProperty(PressurePartContextType.DiameterNominal);
var family = part.GetProperty(PressurePartContextType.PartFamilyName);
if ((string)size == "24 in x 24 in")
if ((string)family == "pipe-push on-ductile iron-350 psi")
{
useThisPart = part;
break;
}
}
if (useThisPart != null)
{
//create the pipe using the found part
}
tr.Commit();
}
@Jeff_M Thanks for the answer, but my problem is Autodesk.Civil.DatabaseServices.Styles.PressurePartList is inaccessible.
Severity Code Description Project File Line Suppression State
Error CS0122 'PressurePartList' is inaccessible due to its protection level Pipes D:\Tubagem\V2\app\Pipes\Civil.cs 102 Active
I using Civil 2020.
I solved this way :
var partslist = tr.GetObject(partslists[0], OpenMode.ForRead);
System.Type objType = System.Type.GetType("Autodesk.Civil.DatabaseServices.Styles.PressurePartList, AeccPressurePipesMgd", false, true);
var myArrayMethodInfo = objType.GetMethods();
var myGetPressPartLists = myArrayMethodInfo[8];
var arParam = new object[1];
arParam[0] = PressurePartDomainType.Pipe;
var pressPartLists = myGetPressPartLists.Invoke(partslist, arParam);
Thanks for the help @Jeff_M
This code works for 2021 Civil3d Only?
I tried on Civil3d 2018 and there is no definition like GetPressurePartListsExt(). It is giving an error in 2018.
It helps to take note of what I put as a comment in the code I posted:
//this is the extension method I have previosuly posted to this forum
var partslists = civdoc.Styles.GetPressurePartListsExt();
Then a search of this forum for GetPressurePartListsExt would give you a link to the thread this post is in:
@harsh.shahVPZTM try this in civil 2021:
public static StyleCollectionBase GetPressurePartsListsExt(StylesRoot styles)
{
var myType = typeof(StylesRootPressurePipesExtension);
var myArrayMethodInfo = myType.GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
StyleCollectionBase pressPartLists;
var myGetPressPartLists = myArrayMethodInfo[0]; // the number 0 here depends on the composition of AeccPressurePipesMgd.dll library
var arParam = new object[1];
arParam[0] = styles;
pressPartLists = myGetPressPartLists.Invoke(null, arParam) as StyleCollectionBase;
return pressPartLists;
}
public static void GetCatalog()
{
var doc = CivilApplication.ActiveDocument;
using (Transaction tr = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
using (Autodesk.AutoCAD.ApplicationServices.DocumentLock docLock = Application.DocumentManager.MdiActiveDocument.LockDocument())
{
StyleCollectionBase partslists = GetPressurePartsListsExt(doc.Styles);
foreach (var plObj in partslists)
{
//try civil 2021
PressurePartList partList = (PressurePartList)tr.GetObject(plObj, OpenMode.ForRead);
List<PressurePartSize> parts = partslist.GetParts(PressurePartDomainType.Pipe);
List<PressurePartSize> appurtenance = partslist.GetParts(PressurePartDomainType.Appurtenance);
List<PressurePartSize> fitting = partslist.GetParts(PressurePartDomainType.Fitting);
}
}
tr.Dispose();
}
}
in civil 2018, 2019, 2020 you are use the reflexion, something identical to what is in the function GetPressurePartsListsExt, type this
System.Type objTypePressurePart = System.Type.GetType("Autodesk.Civil.DatabaseServices.Styles.PressurePartSize, AeccPressurePipesMgd", false, true);
var myArrayMethodInfo = objTypePressurePartList.GetMethods();
var myGetPressPartLists = myArrayMethodInfo[43]; //key the method to use
myGetPressPartLists.Invoke(partlist, arParam)
@harsh.shahVPZTM try this in civil 2018, 2019, 2020
System.Type objTypePressurePartList = System.Type.GetType("Autodesk.Civil.DatabaseServices.Styles.PressurePartList, AeccPressurePipesMgd", false, true);
var myArrayMethodInfo = objTypePressurePartList.GetMethods();
var myGetPressPartLists = myArrayMethodInfo[8];
var arParam = new object[1];
arParam[0] = PressurePartDomainType.Pipe;
var pressPartListsObj = myGetPressPartLists.Invoke(partslist, arParam);
var pressPartLists = ((IEnumerable)pressPartListsObj).Cast<object>().ToList();
@benkas Hi thank you for your help.
I have got up to the point of getting the pressure part list. From this list, i want to run a loop to check all the parts and their description and compare it with a value i have.
PressurePartSize pSize = null;
foreach (PressurePartSize part in pressPartLists)
{
}
PressurePartSize in C3D 2018-2020, it is protected.
var pressPartLists = ((IEnumerable)pressPartListsObj).Cast<object>().ToList();
From pressPartLists, I am not able to reach the description of a part.
Any idea. Thanks again.
@harsh.shahVPZTM I don't know, maybe something like this:
PressurePartSize pSize = null;
System.Type objTypePressurePartSize = System.Type.GetType("Autodesk.Civil.DatabaseServices.Styles.PressurePartSize, AeccPressurePipesMgd", false, true);
var myArrayMethodInfo = objTypePressurePartList.GetMethods();
var myGetPressPartSize = myArrayMethodInfo[8]; //see method key from myArrayMethodInfo
foreach (PressurePartSize part in pressPartSizes)
{
var arParam = new object[0]; //set number necessary params, in this case zero
arParam[0] = PressurePartDomainType.Pipe;//set params, case necessary
var pressPartListsObj = myGetPressPartSize.Invoke(part, arParam);
var pressPartSizeLists = ((IEnumerable)pressPartListsObj).Cast<object>().ToList();
}
it must be something like this
@harsh.shahVPZTM the best is to use the civil 2021 or 2022.
I had the same problems as you, I changed the version of the civil and most of the problems with the pressure pipes were solved
@harsh.shahVPZTM if you can get the fittings and appurtenances object id to use here
PressurePipeNetwork.AddFitting (ObjectId fittingId)
PressurePipeNetwork.AddAppurtenance (ObjectId appurtenanceId)
tell me please.
saw your post about "Creating Pressure Pipe, Fittings, Appurtenances from Excel Data"
I'm working on an identical project, I can add pipes, but Fittings and Appurtenances I can't.
because I haven't been able to get the objectId of these objects.