How to get elements welded by Weld command from steel tab?

How to get elements welded by Weld command from steel tab?

YarUnderoaker
Collaborator Collaborator
936 Views
3 Replies
Message 1 of 4

How to get elements welded by Weld command from steel tab?

YarUnderoaker
Collaborator
Collaborator

Is it posssible to get elements which welded by element of category OST_StructConnectionWeld?

0 Likes
Accepted solutions (1)
937 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy_tammik
Alumni
Alumni

This is tricky (or maybe impossible) to answer without exploring a sample model, unless someone happens to know off-hand.

 

Have you explored your sample model yourself?

 

Here is the standard approach how to research to find a Revit API solution:

 

https://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-onto...

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 4

YarUnderoaker
Collaborator
Collaborator

Yep, I'm in process. 

 

 

foreach(Subelement subelem in sublist)
{
  if (!subelem.HasParameter(new ElementId(BuiltInParameter.STEEL_ELEM_WELD_MAIN_THICKNESS))) continue;
    			
  Reference rf = subelem.GetReference();
  FilerObject filerObj = this.GetFilerObject(doc, rf);
  WeldLine weld = filerObj as WeldLine;
						 
  IEnumerable<Autodesk.AdvanceSteel.CADLink.Database.ObjectId> ObjList;
  weld.GetConnectedElements(out ObjList, 0);
}

 

 

 

I itterate throught structural connections sublelements and search welding. Then I try to get FillerObject but get null.

 

 

public static FilerObject GetFilerObject(Autodesk.Revit.DB.Document doc, Reference eRef)
{
   FilerObject filerObject = null;
   Autodesk.AdvanceSteel.DocumentManagement.Document curDocAS = DocumentManager.GetCurrentDocument();
   if (null != curDocAS)
   {
      OpenDatabase currentDatabase = curDocAS.CurrentDatabase;
      if (null != currentDatabase)
      {
         Guid uid = SteelElementProperties.GetFabricationUniqueID(doc, eRef);
         string asHandle = currentDatabase.getUidDictionary().GetHandle(uid);
         filerObject = FilerObject.GetFilerObjectByHandle(asHandle);
      }
   }
   return filerObject;
}

 

 

 Something wrong with this subroutine, because I can't get any filer object. I get it from help page of  GetSteelElementProperties class.

0 Likes
Message 4 of 4

YarUnderoaker
Collaborator
Collaborator
Accepted solution

Ok, there is nuance - to get filer object you must do this under fabrication transaction. Next simple macroc show info about weldings between different elements of connection.

		public void GetWeldedElementInfo()
		{
			RVTDocument doc = this.ActiveUIDocument.Document;
			  
		
			StructuralConnectionHandler hnd = StructuralConnectionSelectionUtils.SelectConnection(this.ActiveUIDocument);
			
			if (hnd == null) return;
			
			IList<ElementId> ids = hnd.GetConnectedElementIds();

    		IList<Subelement> sublist = hnd.GetSubelements();
    		
    		List<WeldInfo> WeldInfos = new List<ThisApplication.WeldInfo>();
    		
			using(RvtDwgAddon.FabricationTransaction t = new RvtDwgAddon.FabricationTransaction(doc, true, "SteelSheetParam"))
			{
    		
	    		foreach(Subelement subelem in sublist)
	    		{
	    			if (!subelem.HasParameter(new ElementId(BuiltInParameter.STEEL_ELEM_WELD_MAIN_THICKNESS))) continue; //STEEL_ELEM_PLATE_WEIGHT
	    			
							Reference rf = subelem.GetReference();
							FilerObject filerObj = this.GetFilerObject(doc, rf);
							if (filerObj is WeldPoint)
							{
								WeldPoint weld = filerObj as WeldPoint;
								IEnumerable<Autodesk.AdvanceSteel.CADLink.Database.ObjectId> ObjList;
								weld.GetConnectedElements(out ObjList, 0);
								WeldInfo wc = new WeldInfo(subelem);
								
								foreach(Autodesk.AdvanceSteel.CADLink.Database.ObjectId objId in ObjList)
								{
									FilerObject filerObject = FilerObject.GetFilerObject(objId);
									
									foreach(ElementId eId in ids)
									{
										Element profile = doc.GetElement(eId);
										FilerObject pFiler = this.GetFilerObject(profile);
										if (pFiler.GetUniqueId().Equals(filerObject.GetUniqueId()))
										    {
										    	wc.profiles.Add(profile);
										    	break;
										    }										    
									}
									
									foreach(Subelement subweld in sublist)
									{
										Reference weldrf = subweld.GetReference();
										FilerObject filerObjW = this.GetFilerObject(doc, weldrf);	
										if (filerObjW.GetUniqueId().Equals(filerObject.GetUniqueId()))
										    {
										    	wc.plates.Add(subweld);
										    	break;
										    }
									}
								}
								
								WeldInfos.Add(wc);
							}

	    		}
			}
    		
			string text = "";
			
			foreach(WeldInfo wc in WeldInfos)
			{
				
				text += (wc.weld.GetParameterValue(new ElementId(BuiltInParameter.STEEL_ELEM_WELD_MAIN_TEXT)) as StringParameterValue).Value;
				text += " connected ";
				foreach(Subelement sub in wc.plates)
				{
					Element pe = this.get_ElementParamater(wc.weld, "Пластина.Марка");
					StringParameterValue spv = sub.GetParameterValue(pe.Id) as StringParameterValue;
					if (spv == null) continue;
					
					text += spv.Value + ", ";
				}
				
				foreach(Element prof in wc.profiles)
				{
					Parameter p = prof.LookupParameter("КМ.Профиль");
					text += p.AsString() + ", ";
				}				
				text += "\n";
			}
    		MessageBox.Show(text);
		}		
		
		private Element get_ElementParamater(Subelement sub, string name)
		{
			List<ElementId> paramIds = sub.GetAllParameters().ToList();
			foreach(ElementId paramId in paramIds)
			{
				Element param = sub.Document.GetElement(paramId);
				
				if(param == null) continue;	
				
				if(param.Name == name) return param;
			}
			
			return null;
		}

 

0 Likes