Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Advance Steel Forum
Welcome to Autodesk’s Advance Steel Forums. Share your knowledge, ask questions, and explore popular Advance Steel topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AS 2018 .NET API can't find some methods for AS objects

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
NinovSM
1022 Views, 9 Replies

AS 2018 .NET API can't find some methods for AS objects

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. 

9 REPLIES 9
Message 2 of 10
sorin.brinzaru
in reply to: NinovSM

Hello @NinovSM,

 

1. For the first point there is a class that handles groups (ObjectsGroup) but it misses a method to add/remove elements. So for the moments calling the AstM11CommAddToGroup command seems to be the only way.

 

Sorin

Message 3 of 10
sorin.brinzaru
in reply to: NinovSM

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();
  }
}

 

Message 4 of 10
sorin.brinzaru
in reply to: NinovSM

3. The bolt diameter is in ScrewBoltPattern class that inherits from BoltPattern. You can access it through ScrewDiameter property.

Message 5 of 10
sorin.brinzaru
in reply to: NinovSM

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();
         }
      }
    }
  }
}
Message 6 of 10
NinovSM
in reply to: sorin.brinzaru
Message 7 of 10
NinovSM
in reply to: sorin.brinzaru

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?

 

Message 8 of 10
sorin.brinzaru
in reply to: NinovSM

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

Message 9 of 10
Shtalberg
in reply to: NinovSM

Hello,

 

Can you help, what is "role" variable used for?

Message 10 of 10
NinovSM
in reply to: sorin.brinzaru

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report