Hello All,
I am trying to use a function to create a series of spheres which I have been able to complete. My questions is how do I get the "for loop" to change the Level Name of each sphere, what is the best way to change a objects colour/level etc each time it is created?
Cheers,
Alex
PS, if anyone has a good way to add an "Asset Tag" to a GC custom object I would be really keen to know how.
Hi Alex
For the colour part, see attached. There are 2 methods in here. One with a loop and one using Operation Nodes. I haven't got to the levels, maybe someone will do before me.
For Asset ID, one of the properties of the node will be Catalog Item, you can select one from here or create your own. One of the properties will be ID.
function (CoordinateSystem CS){ for (int i = 0; i < point03.Count; ++i) { Solid so = new Solid(this); so.SphereByCentroidRadius(point03[i], 1.5); so.Color = i; }}
Color by count.dgn
Stuart
Yes, assigning different colors instead of different levels is a better choice. Level input is not replicable, in other words, you can not put two or more level information in the level input. Regarding asset tagging, you may check this out https://www.linkedin.com/posts/anik-mal_solution2020-openbuildings-generativecomponents-activity-6764886298999209984-msmO. I created this during a Hackathon. Feel free to contact me if you have any queries.
Thanks,
Anik
Anik,
That looks very similar to what I am trying to achieve in GC. I am in infrastructure so the out of the box options for objects is not what I am after. Out of interest, those ID's that you have in the model, are they placed in GC or have you just used GC to place the objects then go into OBD and edited the data to have the correct ID? I really would like a way to put the asset tag/ID into the model at the GC stage so that no rework is required if the GC needs to be rerun.
If you documented that whole workflow (start to finish) I think it would help a lot of people out.
I always found it frustrating that I have to create a separate node in order to assign a different level to the sub-lists within (I am also in infrastructure). You could always create a custom node to assign different levels like this:
Hi Ed,
This one is cool. Can you please share the code?Thanks,
Sure, bear in mind I just chucked it together yesterday so it could do with a bit of polish but it gets the job done. The basic concept is:
public NodeUpdateResult SetLevel ( NodeUpdateContext updateContext, [GCDgnModelProvider, GCIn, GCReplicatable] GeometricNode Feature, [GCIn, GCReplicatable] string levelName ) { try { long id = Feature.GCElement().ElementId(); DgnModel model = Session.Instance.GetActiveDgnModel(); Element element = model.FindElementById(new ElementId(ref id)); LevelId levelId = Settings.GetLevelIdFromName(levelName); ElementPropertiesSetter elePropSetter = new ElementPropertiesSetter(); elePropSetter.SetLevel(levelId); elePropSetter.Apply(element); this.SetElement(element); } catch (Exception ex) { return new NodeUpdateResult.TechniqueException(new Exception(String.Format("Error applying element symbology: {0}", ex.ToString()))); } return NodeUpdateResult.Success; }
One thing you still need to consider is how to output the resulting geometry though. If you cast the result as a specific node type then the export function will work, however if you leave the node type as a generic ElementBasedNode this will not get exported at all. For me personally there are a few options that I am currently considering to fix this issue:
I don't think there is a right or wrong answer to this problem, but certainly it needs a bit more thought since it will affect my future development plans and also the end-user experience. The perfect option in mind is if we could somehow cast the node output type at runtime, however this does not seem to be possible due to the nature of type inheritance
Cheers,Ed
Thanks a lot for sharing your valuable knowledge.