Quantcast
Channel: All Revit API Forum posts
Viewing all 66788 articles
Browse latest View live

Re: Revit 2019.1 API breaking change

$
0
0

Firstly, answer your question about the doc of What's new in 2019.1, Yes, the new help doc of RevitAPI.chm which is under the folder of Revit 2019.1 SDK installation includes all the main API update for the version 2019.1, please check that file for all the details. Jeremy will also prepare a blog about the information on http://thebuildingcoder.typepad.com/blog/ as usual, please pay attention to that.

 

Second, for your specific question about throwing exception in Document.GetWorksharingCentralModelPath() when it's not workshared model, unfortunately, it's not listed in the What's New of 2019.1 API Doc, but I confirmed with our Revit developer. Yes, that's what they did intentionally, the reason is because Revit cloud model is a non-workshared model from user's perspective, so Revit will throw exceptions for existing worksharing related methods on a Revit cloud model.      


Re: Known Change Requests – Community Tracking

Re: Revit 2019.1 API breaking change

$
0
0

Thank you for yor quick reply! I think I need a minor clarification here:

 

 wrote: which is under the folder of Revit 2019.1 SDK installation

 

Is this somewhere if I have installed the update using Autodesk Desctop App?  If I have a fresh Revit installation, I would know exactly where's the SDK is located, but know I can't figure it out...

Re: RevitAddinUtility usage and redistribution permissions.

$
0
0

One Revit senior engineering manager says: "I have never seen a license agreement covering this one way or another."

 

On the other hand, the intention has always been clear: freely redistributable.

 

I would go ahead and use it as it is intended.

 

Best regards,

 

Jeremy

 

Re: Revit 2019.1 API breaking change

$
0
0

This is the msi installation of Revit SDK, usually you can download it under Tools section of Revit Developer Centre(2019.1 is still on the way, please wait), since you have Revit SDK 2019.1 already, it must be installed somewhere on your PC, usually, it will be installed under C:\Revit 2019.1 SDK of RevitAPI.chm as shown in the screenshot below:

 Screen Shot 2018-08-17 at 6.17.35 PM.png

 

Re: Set BoundingBox bottom at Level

$
0
0

- thank you for your clear explanation. Now I understand where that number is coming from and I can write my application. Thanks again.

Re: Revit 2019.1 add-in and CEFsharp library

$
0
0

Hi Andrew, Garret, 

 

I want to let you know that the Revit product team is investigating your inquiries above.  We'll update you when we have more info.  Thank you for your patience.  

Re: Random color panel by percentage


Re: site fill pattern

$
0
0

Hello,

 

Which type of view is? (shaded, realistic....) If it is realistic, check the appearance tab of the material to see if it is as you want. If it is shaded check the surface patterns.

Change RibbonItem (Button) Properties at Runtime

$
0
0

I'm trying to essentially toggle a ribbon button's properties at runtime.  I have certain process' lined up to grab the button/RibbonItem instance, but when I attempt to change the button properties, the API returns out of my function having not changed anything.  It's doesn't throw an error or anything - it just doesn't do anything...

 

I essentially iterate through the Ribbon, it's panels and their Source.Items until I find the button I need to adjust.  I tried changing it during the iteration and that didn't work; I tried grabbing the button, creating a copy, assigning the new properties to the copy and then reassigning the button as the copy - that didn't work.... As usual, I'm sure it's just some tiny thing I'm missing.  I've tried a lot, and nothing seems to be wanting to cooperate with me, so I'm seeing how I can change the button at runtime.

 

For the record, the Properties I'm trying to modify are 'Name', 'Tooltip', and 'Image'.

 

Any ideas or direction is greatly appreciated.

 

Don't forget to mark your answers...  It helps the next individual find theirs faster!!

Cheers, 

 

Geoff Overfield

Senior Software Engineer

FabPro, LLC

FP_Logo(2).png

Re: Random color panel by percentage

$
0
0

Hi sacastano76,

 

You can achieve this with relative ease.  You actually aren't too far off, either, believe it or not.

public void ColorMaterials()
{
	Random pRand = new Random();
	int iR, iG, iB;
	Document pDoc = this.ActiveUIDocument.Document;
	var pSolidFillPattern = new FilteredElementCollector(pDoc).OfClass((typeof(FillPatternElement))).OfType<FillPatternElement>().Where<FillPatternElement>(p => p.GetFillPattern().IsSolidFill).ToList().First();
	var lEltsToColor = new FilteredElementCollector(pDoc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_CurtainWallPanels).ToList();
	using (Transaction pTrans = new Transaction(pDoc, "Color Curtain Walls"))
	{
		pTrans.Start();
		foreach (var Elt in lEltsToColor)
		{
			iR = pRand.Next(0, 255);
			iG = pRand.Next(0, 255);
			iB = pRand.Next(0, 255);
			Autodesk.Revit.DB.Color pColor = new Autodesk.Revit.DB.Color(iR, iG, iB);
			OverrideGraphicSettings pGraphics = new OverrideGraphicSettings();
			pGraphics.SetProjectionLineColor(pColor);
			pGraphics.SetProjectionLineWeight(10);
			pGraphics.SetProjectionFillColor(pColor);
			pGraphics.SetCutFillColor(pColor);
			pGraphics.SetProjectionFillPatternId(pSolidFillPattern.Id);
			pGraphics.SetCutFillPatternId(pSolidFillPattern.Id);
			pGraphics.SetProjectionFillPatternVisible(true);
			pGraphics.SetCutFillPatternVisible(true);
			pGraphics.SetSurfaceTransparency(10);
			m_pDoc.ActiveView.SetElementOverrides(pId, pGraphics);
		}
		pTrans.Commit();
	}
}


All you have to do is set the graphics override for the Element - you don't have to go through the Parameters - and trying to do so leaves the possibility for very inconsistent results as you can have multiple parameters with the same name - just different GUID's - that may not necessarily control the thing you're looking for.

 

Hope this helps!!

 

Don't forget to mark your answers...  It helps the next individual find theirs faster!!

Cheers, 

 

Geoff Overfield

Senior Software Engineer

FabPro, LLC

FP_Logo(2).png

using mvvm & wpf with transaction & doc.regenerate()

$
0
0

hi dears

i'm working on simple command
it have wpf form bonded to class as per mvvm methods

i call the wpf from my command and it show up using wpf,show();

i use the form and change data then click the buttom to run command on viewmodel from my form as usual in mvvm to pick the objects and change its data
i can close my form
when selecting the object after that i can see that parameter data has changed as i want but document can't fell that changes and i can't generate the document
my problem is i cant use transaction.start on my mvvm command and ca't regenerate the document to see the changes in the tags
how can i solve that?

many thanks in advance

Re: Sort List elements by value parameter

$
0
0

Thanks, apparently I have to resort to the lambda code which I do not know, any website or blog where I can learn it. Thank you.

Re: How to add subelements to selection?

$
0
0

Absolutely!!

 

UIDocument pUIDoc = this.ActiveUIDocument;
var lSelectedIds = pUIDoc.Selection.GetElementIds().ToList();
List<ElementId> lSubIds = new List<ElementId>();

foreach (var pId in lSelectedIds)
{
	Element pElt = pUIDoc.Document.GetElement(pId);
	if (pElt is FamilyInstance)
	{
		FamilyInstance pFamInst = pElt as FamilyInstance;
		if (pFamInst != null)
			lSubIds.AddRange(pFamInst.GetSubComponentIds());
	}
}

lSelectedIds.AddRange(lSubIds);

Hope that helps.  Let me know if you have any questions about any of that!!

 

Don't forget to mark your answers...  It helps the next individual find theirs faster!!

Cheers, 

 

Geoff Overfield

Senior Software Engineer

FabPro, LLC

FP_Logo(2).png

Set Parameter type Reinforcement Length

$
0
0

Good day, I am trying to assign a value to a shared parameter of type reinforcement length but I do not know why I can not apply it, I have considered it of the Double type but I do not get any modification.

 

foreach (Rebar r in rebar)
{
Parameter ParQC_RebarLength = Parameter(r, "8acbe253-9336-4934-925d-7e2dff0be89d");
Double LongPieza=0;
ParQC_RebarLength.Set(LongPieza);
}

public Parameter Parameter(Element e, String guid)
{
Guid parameterShared = new Guid(guid);
Parameter parameter = e.get_Parameter(parameterShared);
return parameter;
}

Re: Set BoundingBox bottom at Level

Re: Set Parameter type Reinforcement Length

$
0
0

I found the solution, I had a try catch that is blocking a line.

Code optimization

$
0
0

Good day, get the parameters of the concrete elements and assign it to all the bars that are housed in it, the code I have works, however it takes its time to load, I get the impression that there are other ways to do it so that I consume less resources. I appreciate your help, thank you.

 

namespace RebarParameters
{
    class Parametros
    {
        //Instancio a Longitu de Rebar
        LongitudRebar longitudRebar = new LongitudRebar();
        //Devuelve Parametro compartido
        public Parameter Parameter(Element e, String guid)
        {
            Guid parameterShared = new Guid(guid);
            Parameter parameter = e.get_Parameter(parameterShared);
            return parameter;
        }

        public Parameter Parameter(Element e, String lookParameter,Boolean boolean)
        {            
            Parameter parameter = e.LookupParameter(lookParameter);
            return parameter;
        }

        //Devuelve Parametro BuiltInParameter
        public Parameter Parameter(Element e, BuiltInParameter parameterBuild)
        {
            Parameter parameter = e.get_Parameter(parameterBuild);
            return parameter;
        }

        //Devuelve Parametro de tipo BuiltInParameter
        public Parameter Parameter(ElementType et, BuiltInParameter parameterBuild)
        {
            Parameter parameter = et.get_Parameter(parameterBuild);
            return parameter;
        }

        //Devuelve parametro Double 0 si existe error
        public Double ConvertirDouble(Parameter parameter)
        {
            Double dimension;
            try
            {
                dimension = parameter.AsDouble();
            }
            catch (Exception)
            {
                dimension = 0;
            }
            return dimension;
        }
                
        public void GetSetParameterRebar(List<Element> listHost, Document doc)
        {           
            //Metodo parametros
            foreach (Element el in listHost)
            {
                //Parametro de Host
                ElementType HostType = doc.GetElement(el.GetTypeId()) as ElementType;
                Parameter HostTypeComments = Parameter(HostType, BuiltInParameter.ALL_MODEL_TYPE_COMMENTS);
                Parameter HostMark = Parameter(el, "1411f266-da7a-4faa-beb9-3848e3304161");
                Parameter QC_HostSector = Parameter(el, "0818baf0-dce1-4ea4-84ac-2f69fae50a84");
                Parameter QC_HostNivel = Parameter(el, "d25405d0-37af-43c2-be2d-7efc1c792fcc");
                Parameter QC_HostEje = Parameter(el, "2ee543a4-ec44-472e-80c4-520883abe8c0");
                Parameter QC_HostFamilia = Parameter(el, "8ca45e69-853c-4132-9452-8124c3b0f3ef");

                //rebar in host
                IList<Rebar> rebar = RebarHostData.GetRebarHostData(el).GetRebarsInHost();    

                if (rebar.Count != 0)
                {
                    // para cada rebar segun su host
                    List<String> formas = new List<string>();

                    foreach (Rebar r in rebar)
                    {
                        //Parametros Rebar de Ubicacion y Sectorización
                        Parameter partition = Parameter(r, BuiltInParameter.NUMBER_PARTITION_PARAM);
                        Parameter QC_HostMark = Parameter(r, "3be2f711-4769-463b-bda8-39ba39aa578d");
                        Parameter QC_Sector = Parameter(r, "0818baf0-dce1-4ea4-84ac-2f69fae50a84");
                        Parameter QC_Nivel = Parameter(r, "d25405d0-37af-43c2-be2d-7efc1c792fcc");
                        Parameter QC_Eje = Parameter(r, "2ee543a4-ec44-472e-80c4-520883abe8c0");
                        Parameter QC_Familia = Parameter(r, "8ca45e69-853c-4132-9452-8124c3b0f3ef");

                        //Parametros de Dimensiones
                        Parameter ParQC_RebarLength = Parameter(r, "8acbe253-9336-4934-925d-7e2dff0be89d");
                        Parameter ParA = Parameter(r, "A", true);
                        Parameter ParB = Parameter(r, "B", true);
                        Parameter ParC = Parameter(r, "C", true);
                        Parameter ParD = Parameter(r, "D", true);
                        Parameter ParE = Parameter(r, "E", true);
                        Parameter ParF = Parameter(r, "F", true);
                        Parameter ParG = Parameter(r, "G", true);
                        Parameter ParH = Parameter(r, "H", true);
                        Parameter ParI = Parameter(r, "I", true);
                        Parameter ParAlfa = Parameter(r, "fb540c64-8611-416a-9172-681a1847112d");
                        Parameter ParBeta = Parameter(r, "b4aa2db2-c434-4457-88a0-f097a6efd159");
                        Parameter ParGamma = Parameter(r, "da72b204-3415-4298-bc87-3c07fb7b8ce4");
                        Parameter ParQC_Codigo_Forma = Parameter(r, "f1fb3a75-4c81-4cd7-980d-7cc02d561a6c");

                        //definicion de parametros de longitud   
                        String QC_Codigo_Forma = ParQC_Codigo_Forma.AsString();
                        Double a = ConvertirDouble(ParA);
                        Double b = ConvertirDouble(ParB);
                        Double c = ConvertirDouble(ParC);
                        Double d = ConvertirDouble(ParD);
                        Double e = ConvertirDouble(ParE);
                        Double f = ConvertirDouble(ParF);
                        Double g = ConvertirDouble(ParG);
                        Double h = ConvertirDouble(ParH);
                        Double i = ConvertirDouble(ParI);
                        Double alfa = ConvertirDouble(ParAlfa);
                        Double beta = ConvertirDouble(ParBeta);
                        Double gamma = ConvertirDouble(ParGamma);

                        //Calcula la longitud
                        Double LongPieza = longitudRebar.LongitudBarra(QC_Codigo_Forma, a, b, c, d, e, f, g, h, i, alfa, beta, gamma);

                        if (LongPieza == 0)
                        {
                            formas.Add(QC_Codigo_Forma);
                        }

                        using (Transaction t = new Transaction(doc, "Parametros"))
                        {
                            t.Start("Parametros");
                            //Asignar Parametros a rebar                            
                            SetParameter(HostTypeComments, partition);
                            SetParameter(HostMark, QC_HostMark);
                            SetParameter(QC_HostSector, QC_Sector);
                            SetParameter(QC_HostNivel, QC_Nivel);
                            SetParameter(QC_HostEje, QC_Eje);
                            SetParameter(QC_HostFamilia, QC_Familia);
                            SetParameter(LongPieza, ParQC_RebarLength);
                            t.Commit();
                        }
                    }

                    if (formas.Count != 0)
                    {
                        String infoformas = "No se encuentra registrado el código de la forma: ";

                        foreach (string f in formas.Distinct())
                        {
                            infoformas += "\n\t" + f;
                        }
                        TaskDialog.Show("QC Ingenieros", infoformas);
                    }

                }
                else
                {                    
                    TaskDialog.Show("QC Ingenieros", "No se ha encontrado ningun elemento de refuerzo en el elemento: " + el.Id.ToString());
                }

            }
        }

        private void CounColorNumber(List<Rebar> list)
        {
            foreach (Rebar r in list)
            {

            }
        }

        private void SetParameter (Parameter HostParameter,Parameter RebarParameter)
        {
            try
            {
                RebarParameter.Set(HostParameter.AsString());

            }
            catch (Exception)
            {
                              
            }
        }

        private void SetParameter(Double HostParameter, Parameter RebarParameter)
        {
            try
            {
                RebarParameter.Set(HostParameter);

            }
            catch (Exception)
            {

            }
        }

    }
}

Re: How to add subelements to selection?

$
0
0

No, it is subcomponents. But there is new entity - subelements. They has no ElementId, but can be selected in Revit by pushing Tab on it master. 

There is deadlock situation. Structural connection's subelement can be selected nor via schedule neither API.

If user want to write value to some parameters it must manually click one by one each subelement in model.

Re: Can't seem to adjust/align the surface pattern of an object

Viewing all 66788 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>