Hi. I can't find some methods in AS API.
1. How to add AS AtomicElement to ObjectsGroup? Only Select method and SendCommand AstM11CommAddToGroup or may be you know any way?
2. How to Mark (in red) AS AtomicElement? Only Select method and SendCommand _AstM4CommMarkSelAdd or may be you know any way?
3. How to get ScrewDiameter from BoltPattern? Find it for AnchorPattern but not for BoltPattern.
4. How to get Detail(Drawing name or number) for Assembly(MainPart) througth API.
Former colleagues from Romanian ADSK Office help me please.
Solved! Go to Solution.
Solved by sorin.brinzaru. Go to Solution.
Solved by sorin.brinzaru. Go to Solution.
2. If you only just want to color an entity you can use Autocad API:
// Get Autocad entity id from filer object ObjectId reprId = DatabaseManager.GetReprId(beam); Autodesk.AutoCAD.DatabaseServices.ObjectId idAcad = new Autodesk.AutoCAD.DatabaseServices.ObjectId(reprId.AsOldId()); // Use Autocad API to set color of the entity using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()) { Autodesk.AutoCAD.DatabaseServices.Entity ent = tr.GetObject(idAcad, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite) as Autodesk.AutoCAD.DatabaseServices.Entity; if (ent != null) { ent.ColorIndex = 1; tr.Commit(); } }
3. The bolt diameter is in ScrewBoltPattern class that inherits from BoltPattern. You can access it through ScrewDiameter property.
4. I think you can use Autodesk.AdvanceSteel.DerivedDocuments that now exposes functionality to get information about the derived documents (details, BOMs, NCs) from an Advance Steel model. Please see some sample code to get detail information from a model (the model should have registered documents):
Document currDoc = DocumentManager.GetCurrentDocument(); if (currDoc != null) { OpenDatabase currDb = currDoc.CurrentDatabase; //get all derived documents from model (details, BOMs, NCs) DerivedDocument[] docs = KernelServices.GetDerivedDocumentsForDwg(currDb); foreach (var item in docs) { string fullFileName = item.GetFullFileName(); //get the type of the document (detail, BOM, NC) DerivedDocument.eDocType eDocType = item.GetType(); if (eDocType == DerivedDocument.eDocType.kDetail) { DerivedDocumentInfo docInfo = item.GetInfo(); if (docInfo != null) { // detail drawing info string protoName = docInfo.GetPrototypeName(); string dwgNo = ""; string dwgNoPrefix = ""; docInfo.GetDwgNo(out dwgNo, out dwgNoPrefix); // approval status info ConstructionElement.eApprovalStatus approvalStatus = docInfo.GetApprovalStatus(); string approvalComment = docInfo.GetApprovalComment(); string approvalDate = docInfo.GetApprovalDate(); // revision info string revIdx = docInfo.GetLastRevIdx(); string[][] revs = new string[][] { }; docInfo.GetRevisions(ref revs); } // get all objects from the derived document DerivedObject[] derObjs = item.GetDerivedObjects(); foreach (var obj in derObjs) { DerivedObjectInfo info = obj.GetInfo(); string objName = info.GetTitle(); //search for detail information DerivedObjectDetailInfo detInfo = info as DerivedObjectDetailInfo; if (detInfo != null) { DerivedObjectDetailInfo.DetailType detType = detInfo.GetDetailType(); string scale = detInfo.GetScale(); string style = detInfo.GetStyleName(); string date = detInfo.GetDate(); string[] sp = detInfo.GetSinglePartsDetailed(); string[] mp = detInfo.GetMainPartsDetailed(); } } } } }
Hello @sorin.brinzaru
I used this code in AS2018 and it works good:
AcadApplication app = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as AcadApplication; ... Autodesk.AutoCAD.Internal.Utils.SelectObjects(acadIDobjs.ToArray()); app.ActiveDocument.SendCommand("._AstM11CommAddToGroup " + "\"" + role + "\"" + " ");//System.NullReferenceException
But in AS2019 I have System.NullReferenceException in last string.
Do you know how to send complex command in AS 2019?
Hello @NinovSM ,
Advance Steel .NET API doesn't have a method of calling commands so you have to use Autocad dedicated API.
I'm not an Autocad .NET API expert and I'm afraid there is not enough information in the code snippet to diagnose your issue. A working sample would be a better idea. Are you sure the app or the ActiveDocument is not null ? You can also try using other methods to call commands like Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute
(if you don't bother that your command will be executed asynchronously).
Sorin
Could I change drawing number, or API not allow this?
Can't find what you're looking for? Ask the community or share your knowledge.