Trying to very simply create a Wire. Having issues establishing the WireType. Here is the pertinent code:
Connector c1 = null;
Connector c2 = null;
WireType wType = ?????
WiringType wingType = WiringType.Arc;
Wire wire = doc.Create.NewWire(wireCurve, curView, c1, c2, wType, wingType);
How do I set the WireType? There may actually be more things wrong here, but I feel like this is my stumbling block.
Thanks.
Well...I'm not sure how aware you are about the concepts. But you should get the proper wire type which you want to use. Those can be found from the family tree in project (category -> family -> family type/symbol).
Using filtters you can get started. See FilteredElementCollector and ElementIsElementTypeFilter classes. Then you can for example loop trough the found types and check the name etc. You can also combine filters...for example by category could be useful.
I'm sure there's something in SDK samples also about this.
I have a related question, it seems the API should provide a way to draw a wire from one connector to another without specifying a curve to use for the wire, but I don't see any methods that do this.
ElectricalSystem.NewWires, which connects everything in a circuit automagically, is similar to what I want in that it doesn't require the caller to provide curves.
Is there a way to create a wire from one connector to another, without having to explicitly define the curve?
I'll preface this by stating that I am a novice programmer. I'm not at all fluent in C#, so I'm using Dynamo and IronPython script.
I've run into the same problem as the OP in that the WireType parameter is holding me up from creating a new wire; everything else is accessible. I cannot create a new WireType as there are no public constructors. I'm able to extract the WireType name, but am, similarly, unable to cast it as a WireType.
The WireTypeSet and WireTypeSetIterator through .Electrical and WireTypes through .ElectricalSetting all come in empty.
I'm able to locate the BuiltInParameter: RBS_ELEC_WIRE_TYPE through a different iterator, but this doesn't seem usable, at least not through IronPython. I have run into a series of iterators that throw Exceptions when I attempt to interact with them, so, this may be down to some inherent limitation to using IronPython.
I will be looking into the proposed ElementIsElementTypeFilter and FilteredElementCollector to see if these provide a solution. Also, I did notice on a different thread that there seems to be some updates to electrical in the 2015 API, some of these pertaining specifically to wires, so, perhaps this is a problem that has already garnered some attention? Any insight into my predicament would be appreciated. Thank you.
Ok, nevermind. Finally figured it out. Turns out there was a static method in electrical setting thatdid not show up; this allowed me to pull the wire types from the electrical settings. Found it using: http://revitapisearch.com/ . This layout is MUCH preferred to Express