示例#1
0
            public static int GetLineTypeIndex(RhinoDoc doc, SFLineType type)
            {
                Linetype line = null;
                switch (type)
                {
                    case SFLineType.Default:
                        return -1;
                    case SFLineType.Hidden:
                    case SFLineType.Dashed:
                    case SFLineType.DashDot:
                    case SFLineType.Center:
                    case SFLineType.Border:
                    case SFLineType.Dots:
                        line = doc.Linetypes.FirstOrDefault(o => o.Name == type.ToString());
                        break;
                    case SFLineType.myDash:
                    case SFLineType.myDashSmall:
                        var myTypeName = "SF_LineType_" + type.ToString();
                        var l = doc.Linetypes.FirstOrDefault(o => o.Name == myTypeName);
                        if (l == null)
                        {
                            var lineType = new Linetype();
                            lineType.Name = myTypeName;
                            switch (type)
                            {
                                case SFLineType.myDash:
                                    lineType.AppendSegment(0.1, true);
                                    lineType.AppendSegment(0.05, false);
                                    break;
                                case SFLineType.myDashSmall:
                                    lineType.AppendSegment(0.05, true);
                                    lineType.AppendSegment(0.05, false);
                                    break;
                            }
                            var index = doc.Linetypes.Add(lineType);
                            line = doc.Linetypes[index];
                        }
                        else
                        {
                            line = doc.Linetypes[l.LinetypeIndex];

                        }
                        break;
                }

                // return our line index
                if (line != null)
                {
                    return line.LinetypeIndex;
                }

                // default line index - continuous line
                return -1;
            }