这个小问题我还是第一次遇到,平时不怎么注意(RadioButton的Checked).

博客提到遇到一个关于RadioButton的Checked的小问题,平时对此不太注意。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.Runtime; using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Windows.Forms; using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application; namespace BeamSectionPlugin { public class BeamSectionDrawer { private static BeamSettings settings = new BeamSettings(); private static readonly HashSet<string> loadedDatabases = new HashSet<string>(); private static Point3d? lastBeamEnd = null; private static double? lastSlabZ = null; [CommandMethod("DB")] public void DrawBeamSection() { Document doc = AcadApp.DocumentManager.MdiActiveDocument; if (doc == null) return; Editor ed = doc.Editor; Database db = doc.Database; // 加载设置窗体 DialogResult dialogResult; using (var form = new SettingsForm(settings)) { dialogResult = AcadApp.ShowModalDialog(form); } if (dialogResult != DialogResult.OK) return; // 保存原始系统变量设置 int oldOrthoMode = Convert.ToInt32(AcadApp.GetSystemVariable("ORTHOMODE")); int oldPolarMode = Convert.ToInt32(AcadApp.GetSystemVariable("POLARMODE")); int oldPolarAddMode = Convert.ToInt32(AcadApp.GetSystemVariable("POLARADDANG")); try { // 启用正交模式和极轴追踪 AcadApp.SetSystemVariable("ORTHOMODE", 1); AcadApp.SetSystemVariable("POLARMODE", 1); // 启用极轴追踪 AcadApp.SetSystemVariable("POLARADDANG", 90); // 设置90度增量角 // 重置连续绘制状态 lastBeamEnd = null; lastSlabZ = null; while (true) { try { Point3d firstPoint; // 步骤1: 获取梁的第一点 if (lastBeamEnd.HasValue) { string continuePrompt = "\n请点击梁的第一点 (或按回车从上一端点继续): "; PromptPointOptions firstPointOpts = new PromptPointOptions(continuePrompt); firstPointOpts.AllowNone = true; PromptPointResult firstPointRes = ed.GetPoint(firstPointOpts); if (firstPointRes.Status == PromptStatus.None) { // 用户按回车,使用上一端点 firstPoint = lastBeamEnd.Value; } else if (firstPointRes.Status == PromptStatus.OK) { firstPoint = firstPointRes.Value; } else { return; // 用户取消 } } else { PromptPointResult firstPointRes = ed.GetPoint("\n请点击梁的第一点: "); if (firstPointRes.Status != PromptStatus.OK) return; firstPoint = firstPointRes.Value; } // 步骤2: 获取梁的第二点 Point3d secondPoint; if (!lastBeamEnd.HasValue) // 第一次绘制 { PromptPointResult secondPointRes = ed.GetPoint("\n请点击梁的第二点: "); if (secondPointRes.Status != PromptStatus.OK) return; secondPoint = secondPointRes.Value; } else // 连续绘制 { PromptPointOptions secondPointOpts = new PromptPointOptions("\n请点击梁的第二点[板厚(A)升降板(S)]: "); secondPointOpts.Keywords.Add("A"); secondPointOpts.Keywords.Add("S"); secondPointOpts.AllowNone = true; secondPointOpts.UseBasePoint = true; secondPointOpts.BasePoint = firstPoint; secondPointOpts.UseDashedLine = true; PromptPointResult secondPointRes = ed.GetPoint(secondPointOpts); while (secondPointRes.Status == PromptStatus.Keyword) { if (secondPointRes.StringResult == "A") { PromptDoubleOptions pdo = new PromptDoubleOptions("\n输入板厚(mm)<" + settings.SlabThickness.ToString() + ">: "); pdo.DefaultValue = settings.SlabThickness; pdo.UseDefaultValue = true; PromptDoubleResult slabThicknessRes = ed.GetDouble(pdo); if (slabThicknessRes.Status != PromptStatus.OK) return; settings.SlabThickness = slabThicknessRes.Value; } else if (secondPointRes.StringResult == "S") { PromptDoubleOptions pdo = new PromptDoubleOptions("\n请输入升降板高度(升板为正数,降板为负数)mm<" + settings.SlabHeightOffset.ToString() + ">: "); pdo.DefaultValue = settings.SlabHeightOffset; pdo.UseDefaultValue = true; PromptDoubleResult slabHeightRes = ed.GetDouble(pdo); if (slabHeightRes.Status != PromptStatus.OK) return; settings.SlabHeightOffset = slabHeightRes.Value; } secondPointRes = ed.GetPoint(secondPointOpts); } if (secondPointRes.Status != PromptStatus.OK) return; secondPoint = secondPointRes.Value; } // 确保两点不在同一位置 if (firstPoint.DistanceTo(secondPoint) < 0.001) { ed.WriteMessage("\n错误: 两点位置相同,请重新选择"); continue; } // 步骤3: 获取梁高 PromptDoubleOptions heightOpts = new PromptDoubleOptions("\n请输入梁高(mm)<" + settings.BeamHeight.ToString() + ">: "); heightOpts.DefaultValue = settings.BeamHeight; heightOpts.UseDefaultValue = true; heightOpts.AllowNegative = false; heightOpts.AllowZero = false; PromptDoubleResult beamHeightRes = ed.GetDouble(heightOpts); if (beamHeightRes.Status != PromptStatus.OK) return; double beamHeight = beamHeightRes.Value; settings.BeamHeight = beamHeight; // 计算板底高度 double slabZ = firstPoint.Z + beamHeight + settings.SlabThickness + settings.SlabHeightOffset; // 处理连续绘制时的板底高度变化 if (lastSlabZ.HasValue && Math.Abs(slabZ - lastSlabZ.Value) > 0.001) { // 绘制升降板竖线 DrawVerticalLine(db, lastBeamEnd.Value, lastSlabZ.Value, slabZ); } // 预加载所需块 LoadSupportBlocks(db, new[] { "ScaffoldPole梁侧模", "ScaffoldPole断面木方", "ScaffoldPole断面方钢", "ScaffoldPole横向龙骨" }); // 步骤4: 绘制梁侧模 if (settings.DrawBeamFormwork) DrawBeamFormwork(db, firstPoint, secondPoint, beamHeight); // 步骤5: 绘制板底线 DrawSlabLine(db, firstPoint, secondPoint, beamHeight); // 步骤6: 如果是连续绘制,绘制板下龙骨 if (lastBeamEnd.HasValue && settings.DrawSlabSupport) { DrawSlabSupport(db, firstPoint, secondPoint, beamHeight); } // 更新连续绘制状态 lastBeamEnd = secondPoint; lastSlabZ = slabZ; } catch (System.Exception ex) { ed.WriteMessage($"\n错误: {ex.Message}\n{ex.StackTrace}"); string dbKey = db.Filename ?? db.GetHashCode().ToString(); loadedDatabases.Remove(dbKey); } } } finally { // 恢复原始系统变量设置 AcadApp.SetSystemVariable("ORTHOMODE", oldOrthoMode); AcadApp.SetSystemVariable("POLARMODE", oldPolarMode); AcadApp.SetSystemVariable("POLARADDANG", oldPolarAddMode); } } private void DrawVerticalLine(Database db, Point3d startPoint, double startZ, double endZ) { using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); Line verticalLine = new Line( new Point3d(startPoint.X, startPoint.Y, startZ), new Point3d(startPoint.X, startPoint.Y, endZ) ); btr.AppendEntity(verticalLine); tr.AddNewlyCreatedDBObject(verticalLine, true); tr.Commit(); } } private void DrawSlabLine(Database db, Point3d beamStart, Point3d beamEnd, double beamHeight) { using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); // 计算板底高度 double slabZ = beamStart.Z + beamHeight + settings.SlabThickness + settings.SlabHeightOffset; Line slabLine = new Line( new Point3d(beamStart.X, beamStart.Y, slabZ), new Point3d(beamEnd.X, beamEnd.Y, slabZ) ); btr.AppendEntity(slabLine); tr.AddNewlyCreatedDBObject(slabLine, true); tr.Commit(); } } private void LoadSupportBlocks(Database db, IEnumerable<string> requiredBlocks) { string dbKey = db.Filename ?? db.GetHashCode().ToString(); if (loadedDatabases.Contains(dbKey)) return; // 1. 尝试加载合并的块文件 string blockFilePath = FindBlockFile(); if (!string.IsNullOrEmpty(blockFilePath)) { using (Database sourceDb = new Database(false, true)) { sourceDb.ReadDwgFile(blockFilePath, FileOpenMode.OpenForReadAndAllShare, false, null); using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); foreach (string blockName in requiredBlocks) { if (!bt.Has(blockName)) { // 复制块定义 db.Insert(blockName, sourceDb, true); } } tr.Commit(); } } loadedDatabases.Add(dbKey); return; } // 2. 如果找不到合并文件,尝试加载单个块文件 string currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string blockDir = Path.Combine(currentDir, "ScaffoldBlocks"); if (!Directory.Exists(blockDir)) { // 尝试在父目录中查找 blockDir = Path.Combine(Directory.GetParent(currentDir).FullName, "ScaffoldBlocks"); if (!Directory.Exists(blockDir)) { loadedDatabases.Add(dbKey); throw new FileNotFoundException("支撑块定义文件未找到,请确认ScaffoldBlocks目录存在"); } } using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); foreach (string blockName in requiredBlocks) { if (bt.Has(blockName)) continue; string blockFile = Path.Combine(blockDir, blockName + ".dwg"); if (!File.Exists(blockFile)) { throw new FileNotFoundException($"找不到图块文件: {blockFile}"); } using (Database sourceDb = new Database(false, true)) { sourceDb.ReadDwgFile(blockFile, FileOpenMode.OpenForReadAndAllShare, false, null); db.Insert(blockName, sourceDb, true); } } tr.Commit(); } loadedDatabases.Add(dbKey); } private string FindBlockFile() { string currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // 1. 检查ScaffoldBlocks子目录 string blockFile = Path.Combine(currentDir, "ScaffoldBlocks", "ScaffoldBlocks.dwg"); if (File.Exists(blockFile)) return blockFile; // 2. 检查当前目录 blockFile = Path.Combine(currentDir, "ScaffoldBlocks.dwg"); if (File.Exists(blockFile)) return blockFile; // 3. 安全获取AutoCAD支持路径 string acadPaths = ""; try { if (AcadApp.MainWindow != null) { object supportVar = AcadApp.GetSystemVariable("SUPPORT"); if (supportVar != null) acadPaths = supportVar.ToString(); } } catch { acadPaths = ""; } // 4. 检查所有支持路径 if (!string.IsNullOrEmpty(acadPaths)) { char[] separators = new char[] { ';', ',' }; foreach (string path in acadPaths.Split(separators, StringSplitOptions.RemoveEmptyEntries)) { try { // 检查路径根目录 blockFile = Path.Combine(path.Trim(), "ScaffoldBlocks.dwg"); if (File.Exists(blockFile)) return blockFile; // 检查路径下的ScaffoldBlocks子目录 blockFile = Path.Combine(path.Trim(), "ScaffoldBlocks", "ScaffoldBlocks.dwg"); if (File.Exists(blockFile)) return blockFile; } catch { /* 忽略无效路径 */ } } } // 5. 检查标准插件目录 string[] pluginPaths = new string[] { Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Autodesk", "ApplicationPlugins", "BeamSectionPlugin.bundle"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Autodesk", "ApplicationPlugins", "BeamSectionPlugin.bundle") }; foreach (string pluginDir in pluginPaths) { try { // 检查插件目录 blockFile = Path.Combine(pluginDir, "ScaffoldBlocks.dwg"); if (File.Exists(blockFile)) return blockFile; // 检查插件目录下的ScaffoldBlocks子目录 blockFile = Path.Combine(pluginDir, "ScaffoldBlocks", "ScaffoldBlocks.dwg"); if (File.Exists(blockFile)) return blockFile; } catch { /* 忽略异常 */ } } // 6. 最终检查程序集所在目录的子目录 try { blockFile = Path.Combine(currentDir, "Resources", "ScaffoldBlocks.dwg"); if (File.Exists(blockFile)) return blockFile; blockFile = Path.Combine(currentDir, "Resources", "ScaffoldBlocks", "ScaffoldBlocks.dwg"); if (File.Exists(blockFile)) return blockFile; } catch { } return null; } private void DrawBeamFormwork(Database db, Point3d start, Point3d end, double beamHeight) { double length = start.DistanceTo(end); double halfLength = length / 2; using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); const string beamBlockName = "ScaffoldPole梁侧模"; if (!bt.Has(beamBlockName)) throw new InvalidOperationException($"找不到图块 '{beamBlockName}',请确认ScaffoldBlocks目录存在"); // 计算中点作为插入点 Point3d midPoint = new Point3d( (start.X + end.X) / 2, (start.Y + end.Y) / 2, start.Z ); BlockReference beamRef = new BlockReference(midPoint, bt[beamBlockName]); btr.AppendEntity(beamRef); tr.AddNewlyCreatedDBObject(beamRef, true); // 计算调整后的梁高 double adjustedBeamHeight = beamHeight - settings.SlabThickness; if (adjustedBeamHeight < 50) adjustedBeamHeight = 50; // 设置动态块参数 bool leftDistanceSet = false; bool rightDistanceSet = false; bool beamHeightSet = false; bool lBeamHeightSet = false; bool mBeamHeightSet = false; foreach (DynamicBlockReferenceProperty prop in beamRef.DynamicBlockReferencePropertyCollection) { string propName = prop.PropertyName.ToLower(); if (propName.Contains("左侧") || propName.Contains("左距离")) { prop.Value = settings.BeamWidth / 2; leftDistanceSet = true; } else if (propName.Contains("右侧") || propName.Contains("右距离")) { prop.Value = settings.BeamWidth / 2; rightDistanceSet = true; } else if (propName.Contains("梁高") && !propName.Contains("l梁高") && !propName.Contains("m梁高")) { prop.Value = adjustedBeamHeight; beamHeightSet = true; } else if (propName.Contains("l梁高")) { prop.Value = adjustedBeamHeight; lBeamHeightSet = true; } else if (propName.Contains("m梁高")) { prop.Value = adjustedBeamHeight; mBeamHeightSet = true; } } // 检查所有必要参数是否已设置 if (!leftDistanceSet || !rightDistanceSet || !beamHeightSet || !lBeamHeightSet || !mBeamHeightSet) { // 如果动态属性未设置,使用更可靠的方法 ed.WriteMessage("\n警告: 未找到所有动态属性,将使用替代方法设置块参数"); // 这里可以添加替代设置方法 } // 旋转图块 Vector3d direction = end - start; double angle = direction.GetAngleTo(Vector3d.XAxis); beamRef.TransformBy(Matrix3d.Rotation(angle, Vector3d.ZAxis, midPoint)); tr.Commit(); } } private void DrawSlabSupport(Database db, Point3d beamStart, Point3d beamEnd, double beamHeight) { if (!settings.DrawSlabSupport) return; Vector3d beamDirection = (beamEnd - beamStart).GetNormal(); double beamLength = beamStart.DistanceTo(beamEnd); // 计算板底位置 double slabZOffset = beamHeight + settings.SlabThickness + settings.SlabHeightOffset; Point3d slabStart = new Point3d(beamStart.X, beamStart.Y, beamStart.Z + slabZOffset); Point3d slabEnd = new Point3d(beamEnd.X, beamEnd.Y, beamEnd.Z + slabZOffset); using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); if (settings.SlabMainDirection == "横向") { // 根据材料选择图块 string blockName = settings.SlabSecondaryMaterial.Contains("方钢") ? "ScaffoldPole断面方钢" : "ScaffoldPole断面木方"; if (!bt.Has(blockName)) throw new InvalidOperationException($"找不到图块 '{blockName}',请确认ScaffoldBlocks目录存在"); // 计算阵列数量和间距 int arrayCount = Math.Max(2, (int)Math.Ceiling(beamLength / settings.SlabSecondarySpacing)); double spacing = beamLength / (arrayCount - 1); for (int i = 0; i < arrayCount; i++) { Point3d position = slabStart + (beamDirection * (i * spacing)); BlockReference supportRef = new BlockReference(position, bt[blockName]); btr.AppendEntity(supportRef); tr.AddNewlyCreatedDBObject(supportRef, true); // 设置材料尺寸 foreach (DynamicBlockReferenceProperty prop in supportRef.DynamicBlockReferencePropertyCollection) { string propName = prop.PropertyName.ToLower(); if (propName.Contains("宽度")) { prop.Value = settings.SlabSecondaryWidth; } else if (propName.Contains("高度")) { prop.Value = settings.SlabSecondaryHeight; } } // 根据方向决定是否旋转 double angle = 0; if (settings.SlabMainDirection == "横向") { // 横向方向 - 无需旋转 angle = 0; } else { // 纵向方向 - 旋转90度 angle = Math.PI / 2; } supportRef.TransformBy(Matrix3d.Rotation(angle, Vector3d.ZAxis, position)); } } else { // 纵向龙骨:单根横向龙骨 const string slabBlockName = "ScaffoldPole横向龙骨"; if (!bt.Has(slabBlockName)) throw new InvalidOperationException($"找不到图块 '{slabBlockName}',请确认ScaffoldBlocks目录存在"); Point3d center = new Point3d( (slabStart.X + slabEnd.X) / 2, (slabStart.Y + slabEnd.Y) / 2, slabStart.Z ); BlockReference supportRef = new BlockReference(center, bt[slabBlockName]); btr.AppendEntity(supportRef); tr.AddNewlyCreatedDBObject(supportRef, true); // 设置长度属性和尺寸 foreach (DynamicBlockReferenceProperty prop in supportRef.DynamicBlockReferencePropertyCollection) { string propName = prop.PropertyName.ToLower(); if (propName.Contains("长度")) { prop.Value = beamLength; } else if (propName.Contains("次龙骨宽")) { prop.Value = settings.SlabSecondaryWidth; } else if (propName.Contains("次龙骨高")) { prop.Value = settings.SlabSecondaryHeight; } } // 旋转方向 Vector3d dir = beamEnd - beamStart; double angle = dir.GetAngleTo(Vector3d.XAxis); supportRef.TransformBy(Matrix3d.Rotation(angle, Vector3d.ZAxis, center)); } tr.Commit(); } } } public class BeamSettings { // 梁参数 public bool DrawBeamFormwork { get; set; } = true; public bool DrawBeamSupport { get; set; } = true; public string BeamMainDirection { get; set; } = "横向"; public double BeamExtension { get; set; } = 50; public double BeamWidth { get; set; } = 300; // 梁宽参数 public double BeamHeight { get; set; } = 700; // 梁高参数 public string BeamMainMaterial { get; set; } = "100方钢"; public string BeamSecondaryMaterial { get; set; } = "50木方"; public double BeamSecondarySpacing { get; set; } = 100; public double BeamSecondaryHeight { get; set; } = 90; public double BeamSecondaryWidth { get; set; } = 40; // 板参数 public double SlabThickness { get; set; } = 250; public bool DrawSlabSupport { get; set; } = true; public string SlabMainDirection { get; set; } = "横向"; public bool KeepSupport { get; set; } = true; public string SlabMainMaterial { get; set; } = "100方钢"; public string SlabSecondaryMaterial { get; set; } = "3木方"; public double SlabSecondarySpacing { get; set; } = 250; public double SlabSecondaryHeight { get; set; } = 90; public double SlabSecondaryWidth { get; set; } = 40; public double SlabHeightOffset { get; set; } = 0; } public class SettingsForm : Form { private BeamSettings settings; private Dictionary<string, Control> controls = new Dictionary<string, Control>(); public SettingsForm(BeamSettings settings) { this.settings = settings; InitializeForm(); this.FormClosing += SettingsForm_FormClosing; } private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e) { if (this.DialogResult == DialogResult.OK) { SaveFormData(); } } private void SaveFormData() { // 梁侧模设置 settings.DrawBeamFormwork = ((RadioButton)controls["rbBeamFormworkYes"]).Checked; settings.DrawBeamSupport = ((RadioButton)controls["rbBeamSupportYes"]).Checked; settings.BeamMainDirection = ((RadioButton)controls["rbBeamHorizontal"]).Checked ? "横向" : "纵向"; settings.BeamExtension = double.Parse(((TextBox)controls["tbBeamExtension"]).Text); settings.BeamMainMaterial = ((ComboBox)controls["cbBeamMainMaterial"]).Text; settings.BeamSecondaryMaterial = ((ComboBox)controls["cbBeamSecondaryMaterial"]).Text; settings.BeamSecondarySpacing = double.Parse(((TextBox)controls["tbBeamSecondarySpacing"]).Text); settings.BeamSecondaryHeight = double.Parse(((TextBox)controls["tbBeamSecondaryHeight"]).Text); settings.BeamSecondaryWidth = double.Parse(((TextBox)controls["tbBeamSecondaryWidth"]).Text); // 板设置 settings.SlabThickness = double.Parse(((TextBox)controls["tbSlabThickness"]).Text); settings.DrawSlabSupport = ((RadioButton)controls["rbSlabSupportYes"]).Checked; settings.SlabMainDirection = ((RadioButton)controls["rbSlabHorizontal"]).Checked ? "横向" : "纵向"; settings.SlabMainMaterial = ((ComboBox)controls["cbSlabMainMaterial"]).Text; settings.SlabSecondaryMaterial = ((ComboBox)controls["cbSlabSecondaryMaterial"]).Text; settings.SlabSecondarySpacing = double.Parse(((TextBox)controls["tbSlabSpacing"]).Text); settings.SlabSecondaryHeight = double.Parse(((TextBox)controls["tbSlabSecondaryHeight"]).Text); settings.SlabSecondaryWidth = double.Parse(((TextBox)controls["tbSlabSecondaryWidth"]).Text); } private void InitializeForm() { this.Text = "梁板剖面绘制参数设置"; this.Size = new System.Drawing.Size(450, 650); // 高度减少 this.FormBorderStyle = FormBorderStyle.FixedDialog; this.StartPosition = FormStartPosition.CenterScreen; TabControl tabControl = new TabControl(); tabControl.Dock = DockStyle.Fill; // 梁下龙骨选项卡 TabPage beamTab = new TabPage("梁下龙骨"); InitializeBeamTab(beamTab); // 板下龙骨选项卡 TabPage slabTab = new TabPage("板下龙骨"); InitializeSlabTab(slabTab); tabControl.TabPages.Add(beamTab); tabControl.TabPages.Add(slabTab); // 按钮面板 Panel buttonPanel = new Panel(); buttonPanel.Dock = DockStyle.Bottom; buttonPanel.Height = 50; Button okButton = new Button(); okButton.Text = "开始绘制"; okButton.DialogResult = DialogResult.OK; okButton.Location = new System.Drawing.Point(120, 10); okButton.Size = new System.Drawing.Size(90, 30); Button cancelButton = new Button(); cancelButton.Text = "取消"; cancelButton.DialogResult = DialogResult.Cancel; cancelButton.Location = new System.Drawing.Point(240, 10); cancelButton.Size = new System.Drawing.Size(90, 30); buttonPanel.Controls.Add(okButton); buttonPanel.Controls.Add(cancelButton); this.Controls.Add(tabControl); this.Controls.Add(buttonPanel); } private void InitializeBeamTab(TabPage tab) { tab.Controls.Clear(); tab.AutoScroll = true; int yPos = 20; // 绘制梁侧模 GroupBox gbBeamFormwork = new GroupBox(); gbBeamFormwork.Text = "绘制梁侧模"; gbBeamFormwork.Location = new System.Drawing.Point(20, yPos); gbBeamFormwork.Size = new System.Drawing.Size(380, 50); RadioButton rbBeamFormworkYes = new RadioButton(); rbBeamFormworkYes.Text = "是"; rbBeamFormworkYes.Checked = settings.DrawBeamFormwork; rbBeamFormworkYes.Location = new System.Drawing.Point(30, 20); controls.Add("rbBeamFormworkYes", rbBeamFormworkYes); RadioButton rbBeamFormworkNo = new RadioButton(); rbBeamFormworkNo.Text = "否"; rbBeamFormworkNo.Checked = !settings.DrawBeamFormwork; rbBeamFormworkNo.Location = new System.Drawing.Point(200, 20); controls.Add("rbBeamFormworkNo", rbBeamFormworkNo); gbBeamFormwork.Controls.Add(rbBeamFormworkYes); gbBeamFormwork.Controls.Add(rbBeamFormworkNo); tab.Controls.Add(gbBeamFormwork); yPos += 60; // 绘制梁龙骨 GroupBox gbBeamSupport = new GroupBox(); gbBeamSupport.Text = "绘制梁龙骨"; gbBeamSupport.Location = new System.Drawing.Point(20, yPos); gbBeamSupport.Size = new System.Drawing.Size(380, 50); RadioButton rbBeamSupportYes = new RadioButton(); rbBeamSupportYes.Text = "是"; rbBeamSupportYes.Checked = settings.DrawBeamSupport; rbBeamSupportYes.Location = new System.Drawing.Point(30, 20); controls.Add("rbBeamSupportYes", rbBeamSupportYes); RadioButton rbBeamSupportNo = new RadioButton(); rbBeamSupportNo.Text = "否"; rbBeamSupportNo.Checked = !settings.DrawBeamSupport; rbBeamSupportNo.Location = new System.Drawing.Point(200, 20); controls.Add("rbBeamSupportNo", rbBeamSupportNo); gbBeamSupport.Controls.Add(rbBeamSupportYes); gbBeamSupport.Controls.Add(rbBeamSupportNo); tab.Controls.Add(gbBeamSupport); yPos += 60; // 主龙骨方向 GroupBox gbBeamDirection = new GroupBox(); gbBeamDirection.Text = "主龙骨方向"; gbBeamDirection.Location = new System.Drawing.Point(20, yPos); gbBeamDirection.Size = new System.Drawing.Size(380, 100); RadioButton rbBeamHorizontal = new RadioButton(); rbBeamHorizontal.Text = "横向"; rbBeamHorizontal.Checked = (settings.BeamMainDirection == "横向"); rbBeamHorizontal.Location = new System.Drawing.Point(30, 20); controls.Add("rbBeamHorizontal", rbBeamHorizontal); RadioButton rbBeamVertical = new RadioButton(); rbBeamVertical.Text = "纵向"; rbBeamVertical.Checked = (settings.BeamMainDirection == "纵向"); rbBeamVertical.Location = new System.Drawing.Point(200, 20); controls.Add("rbBeamVertical", rbBeamVertical); Label lblBeamExtension = new Label(); lblBeamExtension.Text = "横龙骨延伸宽度(mm):"; lblBeamExtension.Location = new System.Drawing.Point(30, 60); lblBeamExtension.AutoSize = true; TextBox tbBeamExtension = new TextBox(); tbBeamExtension.Text = settings.BeamExtension.ToString(); tbBeamExtension.Location = new System.Drawing.Point(200, 55); tbBeamExtension.Width = 100; controls.Add("tbBeamExtension", tbBeamExtension); gbBeamDirection.Controls.Add(rbBeamHorizontal); gbBeamDirection.Controls.Add(rbBeamVertical); gbBeamDirection.Controls.Add(lblBeamExtension); gbBeamDirection.Controls.Add(tbBeamExtension); tab.Controls.Add(gbBeamDirection); yPos += 110; // 材料设置 GroupBox gbBeamMaterial = new GroupBox(); gbBeamMaterial.Text = "材料设置"; gbBeamMaterial.Location = new System.Drawing.Point(20, yPos); gbBeamMaterial.Size = new System.Drawing.Size(380, 250); // 高度减少 Label lblBeamMainMaterial = new Label(); lblBeamMainMaterial.Text = "主龙骨:"; lblBeamMainMaterial.Location = new System.Drawing.Point(30, 30); lblBeamMainMaterial.AutoSize = true; ComboBox cbBeamMainMaterial = new ComboBox(); cbBeamMainMaterial.Items.AddRange(new object[] { "3木方", "5大方", "50钢包木", "48钢管", "40方钢", "50方钢", "100方钢", "8#槽钢", "10#槽钢" }); cbBeamMainMaterial.Text = settings.BeamMainMaterial; cbBeamMainMaterial.Location = new System.Drawing.Point(220, 25); cbBeamMainMaterial.Width = 130; controls.Add("cbBeamMainMaterial", cbBeamMainMaterial); Label lblBeamSecondaryMaterial = new Label(); lblBeamSecondaryMaterial.Text = "次龙骨:"; lblBeamSecondaryMaterial.Location = new System.Drawing.Point(30, 70); lblBeamSecondaryMaterial.AutoSize = true; ComboBox cbBeamSecondaryMaterial = new ComboBox(); cbBeamSecondaryMaterial.Items.AddRange(new object[] { "3木方", "5大方", "50钢包木", "48钢管", "40方钢", "50方钢", "100方钢", "8#槽钢", "10#槽钢" }); cbBeamSecondaryMaterial.Text = settings.BeamSecondaryMaterial; cbBeamSecondaryMaterial.Location = new System.Drawing.Point(220, 65); cbBeamSecondaryMaterial.Width = 130; controls.Add("cbBeamSecondaryMaterial", cbBeamSecondaryMaterial); Label lblBeamSecondarySpacing = new Label(); lblBeamSecondarySpacing.Text = "次龙骨间距(mm):"; lblBeamSecondarySpacing.Location = new System.Drawing.Point(30, 110); lblBeamSecondarySpacing.AutoSize = true; TextBox tbBeamSecondarySpacing = new TextBox(); tbBeamSecondarySpacing.Text = settings.BeamSecondarySpacing.ToString(); tbBeamSecondarySpacing.Location = new System.Drawing.Point(220, 105); tbBeamSecondarySpacing.Width = 130; controls.Add("tbBeamSecondarySpacing", tbBeamSecondarySpacing); Label lblBeamSecondaryWidth = new Label(); lblBeamSecondaryWidth.Text = "次龙骨宽(mm):"; lblBeamSecondaryWidth.Location = new System.Drawing.Point(30, 150); lblBeamSecondaryWidth.AutoSize = true; TextBox tbBeamSecondaryWidth = new TextBox(); tbBeamSecondaryWidth.Text = settings.BeamSecondaryWidth.ToString(); tbBeamSecondaryWidth.Location = new System.Drawing.Point(220, 145); tbBeamSecondaryWidth.Width = 130; controls.Add("tbBeamSecondaryWidth", tbBeamSecondaryWidth); Label lblBeamSecondaryHeight = new Label(); lblBeamSecondaryHeight.Text = "次龙骨高(mm):"; lblBeamSecondaryHeight.Location = new System.Drawing.Point(30, 190); lblBeamSecondaryHeight.AutoSize = true; TextBox tbBeamSecondaryHeight = new TextBox(); tbBeamSecondaryHeight.Text = settings.BeamSecondaryHeight.ToString(); tbBeamSecondaryHeight.Location = new System.Drawing.Point(220, 185); tbBeamSecondaryHeight.Width = 130; controls.Add("tbBeamSecondaryHeight", tbBeamSecondaryHeight); gbBeamMaterial.Controls.Add(lblBeamMainMaterial); gbBeamMaterial.Controls.Add(cbBeamMainMaterial); gbBeamMaterial.Controls.Add(lblBeamSecondaryMaterial); gbBeamMaterial.Controls.Add(cbBeamSecondaryMaterial); gbBeamMaterial.Controls.Add(lblBeamSecondarySpacing); gbBeamMaterial.Controls.Add(tbBeamSecondarySpacing); gbBeamMaterial.Controls.Add(lblBeamSecondaryWidth); gbBeamMaterial.Controls.Add(tbBeamSecondaryWidth); gbBeamMaterial.Controls.Add(lblBeamSecondaryHeight); gbBeamMaterial.Controls.Add(tbBeamSecondaryHeight); tab.Controls.Add(gbBeamMaterial); } private void InitializeSlabTab(TabPage tab) { tab.Controls.Clear(); tab.AutoScroll = true; int yPos = 20; // 默认板厚 GroupBox gbSlabThickness = new GroupBox(); gbSlabThickness.Text = "板厚设置"; gbSlabThickness.Location = new System.Drawing.Point(20, yPos); gbSlabThickness.Size = new System.Drawing.Size(380, 60); TextBox tbSlabThickness = new TextBox(); tbSlabThickness.Text = settings.SlabThickness.ToString(); tbSlabThickness.Location = new System.Drawing.Point(220, 20); tbSlabThickness.Width = 130; controls.Add("tbSlabThickness", tbSlabThickness); gbSlabThickness.Controls.Add(new Label() { Text = "默认板厚(mm):", Location = new System.Drawing.Point(30, 25), AutoSize = true }); gbSlabThickness.Controls.Add(tbSlabThickness); tab.Controls.Add(gbSlabThickness); yPos += 70; // 绘制板龙骨 GroupBox gbDrawSlabSupport = new GroupBox(); gbDrawSlabSupport.Text = "绘制板龙骨"; gbDrawSlabSupport.Location = new System.Drawing.Point(20, yPos); gbDrawSlabSupport.Size = new System.Drawing.Size(380, 60); RadioButton rbSlabSupportYes = new RadioButton(); rbSlabSupportYes.Text = "是"; rbSlabSupportYes.Checked = settings.DrawSlabSupport; rbSlabSupportYes.Location = new System.Drawing.Point(30, 25); controls.Add("rbSlabSupportYes", rbSlabSupportYes); RadioButton rbSlabSupportNo = new RadioButton(); rbSlabSupportNo.Text = "否"; rbSlabSupportNo.Checked = !settings.DrawSlabSupport; rbSlabSupportNo.Location = new System.Drawing.Point(200, 25); controls.Add("rbSlabSupportNo", rbSlabSupportNo); gbDrawSlabSupport.Controls.Add(rbSlabSupportYes); gbDrawSlabSupport.Controls.Add(rbSlabSupportNo); tab.Controls.Add(gbDrawSlabSupport); yPos += 70; // 主龙骨方向 GroupBox gbSlabDirection = new GroupBox(); gbSlabDirection.Text = "主龙骨方向"; gbSlabDirection.Location = new System.Drawing.Point(20, yPos); gbSlabDirection.Size = new System.Drawing.Size(380, 60); RadioButton rbSlabHorizontal = new RadioButton(); rbSlabHorizontal.Text = "横向"; rbSlabHorizontal.Checked = (settings.SlabMainDirection == "横向"); rbSlabHorizontal.Location = new System.Drawing.Point(30, 25); controls.Add("rbSlabHorizontal", rbSlabHorizontal); RadioButton rbSlabVertical = new RadioButton(); rbSlabVertical.Text = "纵向"; rbSlabVertical.Checked = (settings.SlabMainDirection == "纵向"); rbSlabVertical.Location = new System.Drawing.Point(200, 25); controls.Add("rbSlabVertical", rbSlabVertical); gbSlabDirection.Controls.Add(rbSlabHorizontal); gbSlabDirection.Controls.Add(rbSlabVertical); tab.Controls.Add(gbSlabDirection); yPos += 70; // 次龙骨设置 GroupBox gbSlabSecondary = new GroupBox(); gbSlabSecondary.Text = "龙骨设置"; gbSlabSecondary.Location = new System.Drawing.Point(20, yPos); gbSlabSecondary.Size = new System.Drawing.Size(380, 210); Label lblSlabMainMaterial = new Label(); lblSlabMainMaterial.Text = "主龙骨材料:"; lblSlabMainMaterial.Location = new System.Drawing.Point(30, 30); lblSlabMainMaterial.AutoSize = true; ComboBox cbSlabMainMaterial = new ComboBox(); cbSlabMainMaterial.Items.AddRange(new object[] { "3木方", "5大方", "极钢包木", "48钢管", "40方钢", "50方钢", "100方钢", "8#槽钢", "10#槽钢" }); cbSlabMainMaterial.Text = settings.SlabMainMaterial; cbSlabMainMaterial.Location = new System.Drawing.Point(220, 25); cbSlabMainMaterial.Width = 130; controls.Add("cbSlabMainMaterial", cbSlabMainMaterial); Label lblSlabSecondaryMaterial = new Label(); lblSlabSecondaryMaterial.Text = "次龙骨材料:"; lblSlabSecondaryMaterial.Location = new System.Drawing.Point(30, 70); lblSlabSecondaryMaterial.AutoSize = true; ComboBox cbSlabSecondaryMaterial = new ComboBox(); cbSlabSecondaryMaterial.Items.AddRange(new object[] { "3木方", "5大方", "50钢包木", "48钢管", "40方钢", "50方钢", "100方钢", "8#槽钢", "10#槽钢" }); cbSlabSecondaryMaterial.Text = settings.SlabSecondaryMaterial; cbSlabSecondaryMaterial.Location = new System.Drawing.Point(220, 65); cbSlabSecondaryMaterial.Width = 130; controls.Add("cbSlabSecondaryMaterial", cbSlabSecondaryMaterial); Label lblSlabSpacing = new Label(); lblSlabSpacing.Text = "次龙骨间距(mm):"; lblSlabSpacing.Location = new System.Drawing.Point(30, 110); lblSlabSpacing.AutoSize = true; TextBox tbSlabSpacing = new TextBox(); tbSlabSpacing.Text = settings.SlabSecondarySpacing.ToString(); tbSlabSpacing.Location = new System.Drawing.Point(220, 105); tbSlabSpacing.Width = 130; controls.Add("tbSlabSpacing", tbSlabSpacing); Label lblSlabSecondaryWidth = new Label(); lblSlabSecondaryWidth.Text = "次龙骨宽(mm):"; lblSlabSecondaryWidth.Location = new System.Drawing.Point(30, 150); lblSlabSecondaryWidth.AutoSize = true; TextBox tbSlabSecondaryWidth = new TextBox(); tbSlabSecondaryWidth.Text = settings.SlabSecondaryWidth.ToString(); tbSlabSecondaryWidth.Location = new System.Drawing.Point(220, 145); tbSlabSecondaryWidth.Width = 130; controls.Add("tbSlabSecondaryWidth", tbSlabSecondaryWidth); Label lblSlabSecondaryHeight = new Label(); lblSlabSecondaryHeight.Text = "次龙骨高(mm):"; lblSlabSecondaryHeight.Location = new System.Drawing.Point(30, 190); lblSlabSecondaryHeight.AutoSize = true; TextBox tbSlabSecondaryHeight = new TextBox(); tbSlabSecondaryHeight.Text = settings.SlabSecondaryHeight.ToString(); tbSlabSecondaryHeight.Location = new System.Drawing.Point(220, 185); tbSlabSecondaryHeight.Width = 130; controls.Add("tbSlabSecondaryHeight", tbSlabSecondaryHeight); gbSlabSecondary.Controls.Add(lblSlabMainMaterial); gbSlabSecondary.Controls.Add(cbSlabMainMaterial); gbSlabSecondary.Controls.Add(lblSlabSecondaryMaterial); gbSlabSecondary.Controls.Add(cbSlabSecondaryMaterial); gbSlabSecondary.Controls.Add(lblSlabSpacing); gbSlabSecondary.Controls.Add(tbSlabSpacing); gbSlabSecondary.Controls.Add(lblSlabSecondaryWidth); gbSlabSecondary.Controls.Add(tbSlabSecondaryWidth); gbSlabSecondary.Controls.Add(lblSlabSecondaryHeight); gbSlabSecondary.Controls.Add(tbSlabSecondaryHeight); tab.Controls.Add(gbSlabSecondary); } } } CS0103当前上下文中不存在名称“ed” 修改一套完整代码
08-12
using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Geometry; using System; using System.Collections.Generic; using System.Windows.Forms; using System.Drawing; namespace BeamSlabPlugin { // 参数类定义 public class BeamSlabParameters { public BeamSideSecondaryParameters BeamSideSecondary { get; set; } = new BeamSideSecondaryParameters(); public BeamSidePrimaryParameters BeamSidePrimary { get; set; } = new BeamSidePrimaryParameters(); public BeamBoltParameters BeamBolt { get; set; } = new BeamBoltParameters(); public BeamBottomSecondaryParameters BeamBottomSecondary { get; set; } = new BeamBottomSecondaryParameters(); public BeamBottomPrimaryParameters BeamBottomPrimary { get; set; } = new BeamBottomPrimaryParameters(); public SlabParameters Slab { get; set; } = new SlabParameters(); public double DefaultSlabThickness { get; set; } = 120; public double FormworkThickness { get; set; } = 15; } public class BeamSideSecondaryParameters { public bool Enabled { get; set; } = true; public string Direction { get; set; } = "Vertical"; public string Material { get; set; } = "木方"; public double Height { get; set; } = 90; public double Width { get; set; } = 40; public double Spacing { get; set; } = 200; } public class BeamSidePrimaryParameters { public bool Enabled { get; set; } = true; public string Direction { get; set; } = "Horizontal"; public string Material { get; set; } = "钢管"; public double Height { get; set; } = 100; public double Width { get; set; } = 100; public double Diameter { get; set; } = 48; } public class BeamBoltParameters { public bool Enabled { get; set; } = true; public double BottomOffset { get; set; } = 150; public double TopOffset { get; set; } = 150; public double MaxSpacing { get; set; } = 500; } public class BeamBottomSecondaryParameters { public bool Enabled { get; set; } = true; public string Direction { get; set; } = "Longitudinal"; public string Material { get; set; } = "木方"; public double Height { get; set; } = 90; public double Width { get; set; } = 40; public double Spacing { get; set; } = 200; } public class BeamBottomPrimaryParameters { public bool Enabled { get; set; } = true; public string Material { get; set; } = "钢管"; public double Height { get; set; } = 100; public double Width { get; set; } = 100; } public class SlabParameters { public bool SecondaryEnabled { get; set; } = true; public string SecondaryDirection { get; set; } = "Longitudinal"; public string SecondaryMaterial { get; set; } = "木方"; public double SecondaryHeight { get; set; } = 90; public double SecondaryWidth { get; set; } = 40; public double SecondarySpacing { get; set; } = 200; public bool PrimaryEnabled { get; set; } = true; public string PrimaryMaterial { get; set; } = "钢管"; public double PrimaryHeight { get; set; } = 100; public double PrimaryWidth { get; set; } = 100; } // 参数窗体类 public class ParameterForm : Form { public BeamSlabParameters Parameters { get; private set; } // 梁侧次龙骨控件 private RadioButton radBeamSideSecondaryYes; private RadioButton radBeamSideSecondaryNo; private RadioButton radBeamSideSecondaryHorizontal; private RadioButton radBeamSideSecondaryVertical; private ComboBox cmbBeamSideSecondaryMaterial; private TextBox txtBeamSideSecondaryHeight; private TextBox txtBeamSideSecondaryWidth; private TextBox txtBeamSideSecondarySpacing; // 梁侧主龙骨控件 private RadioButton radBeamSidePrimaryYes; private RadioButton radBeamSidePrimaryNo; private RadioButton radBeamSidePrimaryHorizontal; private RadioButton radBeamSidePrimaryVertical; private ComboBox cmbBeamSidePrimaryMaterial; private TextBox txtBeamSidePrimaryHeight; private TextBox txtBeamSidePrimaryWidth; private TextBox txtBeamSidePrimaryDiameter; // 梁对拉螺栓设置控件 private TextBox txtBeamBoltBottomOffset; private TextBox txtBeamBoltTopOffset; private TextBox txtBeamBoltMaxSpacing; // 梁底次龙骨控件 private RadioButton radBeamBottomSecondaryYes; private RadioButton radBeamBottomSecondaryNo; private RadioButton radBeamBottomSecondaryHorizontal; private RadioButton radBeamBottomSecondaryLongitudinal; private ComboBox cmbBeamBottomSecondaryMaterial; private TextBox txtBeamBottomSecondaryHeight; private TextBox txtBeamBottomSecondaryWidth; private TextBox txtBeamBottomSecondarySpacing; // 梁底主龙骨控件 private RadioButton radBeamBottomPrimaryYes; private RadioButton radBeamBottomPrimaryNo; private ComboBox cmbBeamBottomPrimaryMaterial; private TextBox txtBeamBottomPrimaryHeight; private TextBox txtBeamBottomPrimaryWidth; // 板龙骨设置控件 private TextBox txtDefaultSlabThickness; private TextBox txtFormworkThickness; private RadioButton radSlabSecondaryYes; private RadioButton radSlabSecondaryNo; private RadioButton radSlabSecondaryHorizontal; private RadioButton radSlabSecondaryLongitudinal; private ComboBox cmbSlabSecondaryMaterial; private TextBox txtSlabSecondaryHeight; private TextBox txtSlabSecondaryWidth; private TextBox txtSlabSecondarySpacing; private RadioButton radSlabPrimaryYes; private RadioButton radSlabPrimaryNo; private ComboBox cmbSlabPrimaryMaterial; private TextBox txtSlabPrimaryHeight; private TextBox txtSlabPrimaryWidth; private Button btnOK; private Button btnCancel; public ParameterForm() { Parameters = new BeamSlabParameters(); InitializeComponent(); SetupEventHandlers(); } private void InitializeComponent() { this.Text = "梁板剖面绘制参数设置"; this.Size = new Size(800, 600); // 增加窗体大小以容纳所有控件 this.StartPosition = FormStartPosition.CenterScreen; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; // 创建选项卡控件 TabControl tabControl = new TabControl(); tabControl.Dock = DockStyle.Fill; tabControl.TabPages.Add("梁龙骨设置"); tabControl.TabPages.Add("板龙骨设置"); // 梁龙骨设置页面 TabPage beamPage = tabControl.TabPages[0]; beamPage.AutoScroll = true; // 启用滚动条 InitializeBeamPage(beamPage); // 板龙骨设置页面 TabPage slabPage = tabControl.TabPages[1]; slabPage.AutoScroll = true; // 启用滚动条 InitializeSlabPage(slabPage); // 创建底部面板放置按钮 Panel bottomPanel = new Panel(); bottomPanel.Dock = DockStyle.Bottom; bottomPanel.Height = 50; bottomPanel.BackColor = SystemColors.Control; // 确定和取消按钮 btnOK = new Button(); btnOK.Text = "开始绘制"; btnOK.DialogResult = DialogResult.OK; btnOK.Size = new Size(100, 30); btnOK.Location = new Point(this.Width - 220, 10); btnCancel = new Button(); btnCancel.Text = "取消"; btnCancel.DialogResult = DialogResult.Cancel; btnCancel.Size = new Size(100, 30); btnCancel.Location = new Point(this.Width - 110, 10); bottomPanel.Controls.Add(btnOK); bottomPanel.Controls.Add(btnCancel); this.Controls.Add(tabControl); this.Controls.Add(bottomPanel); } private void InitializeBeamPage(TabPage page) { int yPos = 15; int labelWidth = 120; int controlSpacing = 10; int column1 = 20; int column2 = column1 + labelWidth + controlSpacing; int column3 = column2 + 100; int column4 = column3 + 100; int column5 = column4 + 100; // 标题 Label lblTitle = new Label(); lblTitle.Text = "梁龙骨设置参数"; lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 10, System.Drawing.FontStyle.Bold); lblTitle.Location = new Point(column1, yPos); lblTitle.Size = new Size(250, 20); page.Controls.Add(lblTitle); yPos += 30; // 绘制梁侧次龙骨 Label lblBeamSideSecondary = new Label(); lblBeamSideSecondary.Text = "绘制梁侧次龙骨:"; lblBeamSideSecondary.Location = new Point(column1, yPos); lblBeamSideSecondary.Size = new Size(labelWidth, 20); page.Controls.Add(lblBeamSideSecondary); radBeamSideSecondaryYes = new RadioButton(); radBeamSideSecondaryYes.Text = "是"; radBeamSideSecondaryYes.Checked = true; radBeamSideSecondaryYes.Location = new Point(column2, yPos); radBeamSideSecondaryYes.Size = new Size(40, 20); page.Controls.Add(radBeamSideSecondaryYes); radBeamSideSecondaryNo = new RadioButton(); radBeamSideSecondaryNo.Text = "否"; radBeamSideSecondaryNo.Location = new Point(column2 + 50, yPos); radBeamSideSecondaryNo.Size = new Size(40, 20); page.Controls.Add(radBeamSideSecondaryNo); // 绘制方向 Label lblDirection = new Label(); lblDirection.Text = "绘制方向:"; lblDirection.Location = new Point(column3, yPos); lblDirection.Size = new Size(70, 20); page.Controls.Add(lblDirection); radBeamSideSecondaryHorizontal = new RadioButton(); radBeamSideSecondaryHorizontal.Text = "横向"; radBeamSideSecondaryHorizontal.Location = new Point(column3 + 80, yPos); radBeamSideSecondaryHorizontal.Size = new Size(50, 20); page.Controls.Add(radBeamSideSecondaryHorizontal); radBeamSideSecondaryVertical = new RadioButton(); radBeamSideSecondaryVertical.Text = "竖向"; radBeamSideSecondaryVertical.Location = new Point(column3 + 140, yPos); radBeamSideSecondaryVertical.Size = new Size(50, 20); radBeamSideSecondaryVertical.Checked = true; page.Controls.Add(radBeamSideSecondaryVertical); // 材料 Label lblMaterial = new Label(); lblMaterial.Text = "材料:"; lblMaterial.Location = new Point(column4, yPos); lblMaterial.Size = new Size(50, 20); page.Controls.Add(lblMaterial); cmbBeamSideSecondaryMaterial = new ComboBox(); cmbBeamSideSecondaryMaterial.Items.AddRange(new object[] { "木方", "方钢", "钢管" }); cmbBeamSideSecondaryMaterial.SelectedIndex = 0; cmbBeamSideSecondaryMaterial.Location = new Point(column4 + 50, yPos); cmbBeamSideSecondaryMaterial.Size = new Size(80, 20); page.Controls.Add(cmbBeamSideSecondaryMaterial); yPos += 30; // 规格 Label lblSpec = new Label(); lblSpec.Text = "规格:"; lblSpec.Location = new Point(column2, yPos); lblSpec.Size = new Size(40, 20); page.Controls.Add(lblSpec); Label lblHeight = new Label(); lblHeight.Text = "高:"; lblHeight.Location = new Point(column2 + 50, yPos); lblHeight.Size = new Size(30, 20); page.Controls.Add(lblHeight); txtBeamSideSecondaryHeight = new TextBox(); txtBeamSideSecondaryHeight.Text = "90"; txtBeamSideSecondaryHeight.Location = new Point(column2 + 80, yPos); txtBeamSideSecondaryHeight.Size = new Size(50, 20); page.Controls.Add(txtBeamSideSecondaryHeight); Label lblWidth = new Label(); lblWidth.Text = "宽:"; lblWidth.Location = new Point(column2 + 140, yPos); lblWidth.Size = new Size(30, 20); page.Controls.Add(lblWidth); txtBeamSideSecondaryWidth = new TextBox(); txtBeamSideSecondaryWidth.Text = "40"; txtBeamSideSecondaryWidth.Location = new Point(column2 + 170, yPos); txtBeamSideSecondaryWidth.Size = new Size(50, 20); page.Controls.Add(txtBeamSideSecondaryWidth); Label lblSpacing = new Label(); lblSpacing.Text = "间距:"; lblSpacing.Location = new Point(column2 + 230, yPos); lblSpacing.Size = new Size(40, 20); page.Controls.Add(lblSpacing); txtBeamSideSecondarySpacing = new TextBox(); txtBeamSideSecondarySpacing.Text = "200"; txtBeamSideSecondarySpacing.Location = new Point(column2 + 270, yPos); txtBeamSideSecondarySpacing.Size = new Size(50, 20); page.Controls.Add(txtBeamSideSecondarySpacing); yPos += 40; // 绘制梁侧主龙骨 Label lblBeamSidePrimary = new Label(); lblBeamSidePrimary.Text = "绘制梁侧主龙骨:"; lblBeamSidePrimary.Location = new Point(column1, yPos); lblBeamSidePrimary.Size = new Size(labelWidth, 20); page.Controls.Add(lblBeamSidePrimary); radBeamSidePrimaryYes = new RadioButton(); radBeamSidePrimaryYes.Text = "是"; radBeamSidePrimaryYes.Checked = true; radBeamSidePrimaryYes.Location = new Point(column2, yPos); radBeamSidePrimaryYes.Size = new Size(40, 20); page.Controls.Add(radBeamSidePrimaryYes); radBeamSidePrimaryNo = new RadioButton(); radBeamSidePrimaryNo.Text = "否"; radBeamSidePrimaryNo.Location = new Point(column2 + 50, yPos); radBeamSidePrimaryNo.Size = new Size(40, 20); page.Controls.Add(radBeamSidePrimaryNo); // 绘制方向 Label lblDirection2 = new Label(); lblDirection2.Text = "绘制方向:"; lblDirection2.Location = new Point(column3, yPos); lblDirection2.Size = new Size(70, 20); page.Controls.Add(lblDirection2); radBeamSidePrimaryHorizontal = new RadioButton(); radBeamSidePrimaryHorizontal.Text = "横向"; radBeamSidePrimaryHorizontal.Location = new Point(column3 + 80, yPos); radBeamSidePrimaryHorizontal.Size = new Size(50, 20); radBeamSidePrimaryHorizontal.Checked = true; page.Controls.Add(radBeamSidePrimaryHorizontal); radBeamSidePrimaryVertical = new RadioButton(); radBeamSidePrimaryVertical.Text = "竖向"; radBeamSidePrimaryVertical.Location = new Point(column3 + 140, yPos); radBeamSidePrimaryVertical.Size = new Size(50, 20); page.Controls.Add(radBeamSidePrimaryVertical); // 材料 Label lblMaterial2 = new Label(); lblMaterial2.Text = "材料:"; lblMaterial2.Location = new Point(column4, yPos); lblMaterial2.Size = new Size(50, 20); page.Controls.Add(lblMaterial2); cmbBeamSidePrimaryMaterial = new ComboBox(); cmbBeamSidePrimaryMaterial.Items.AddRange(new object[] { "木方", "方钢", "钢管" }); cmbBeamSidePrimaryMaterial.SelectedIndex = 2; cmbBeamSidePrimaryMaterial.Location = new Point(column4 + 50, yPos); cmbBeamSidePrimaryMaterial.Size = new Size(80, 20); page.Controls.Add(cmbBeamSidePrimaryMaterial); yPos += 30; // 规格 Label lblSpec2 = new Label(); lblSpec2.Text = "规格:"; lblSpec2.Location = new Point(column2, yPos); lblSpec2.Size = new Size(40, 20); page.Controls.Add(lblSpec2); Label lblHeight2 = new Label(); lblHeight2.Text = "高:"; lblHeight2.Location = new Point(column2 + 50, yPos); lblHeight2.Size = new Size(30, 20); page.Controls.Add(lblHeight2); txtBeamSidePrimaryHeight = new TextBox(); txtBeamSidePrimaryHeight.Text = "100"; txtBeamSidePrimaryHeight.Location = new Point(column2 + 80, yPos); txtBeamSidePrimaryHeight.Size = new Size(50, 20); page.Controls.Add(txtBeamSidePrimaryHeight); Label lblWidth2 = new Label(); lblWidth2.Text = "宽:"; lblWidth2.Location = new Point(column2 + 140, yPos); lblWidth2.Size = new Size(30, 20); page.Controls.Add(lblWidth2); txtBeamSidePrimaryWidth = new TextBox(); txtBeamSidePrimaryWidth.Text = "100"; txtBeamSidePrimaryWidth.Location = new Point(column2 + 170, yPos); txtBeamSidePrimaryWidth.Size = new Size(50, 20); page.Controls.Add(txtBeamSidePrimaryWidth); Label lblDiameter = new Label(); lblDiameter.Text = "直径:"; lblDiameter.Location = new Point(column2 + 230, yPos); lblDiameter.Size = new Size(40, 20); page.Controls.Add(lblDiameter); txtBeamSidePrimaryDiameter = new TextBox(); txtBeamSidePrimaryDiameter.Text = "48"; txtBeamSidePrimaryDiameter.Location = new Point(column2 + 270, yPos); txtBeamSidePrimaryDiameter.Size = new Size(50, 20); page.Controls.Add(txtBeamSidePrimaryDiameter); yPos += 40; // 梁对拉螺栓设置 Label lblBeamBolt = new Label(); lblBeamBolt.Text = "梁对拉螺栓设置:"; lblBeamBolt.Location = new Point(column1, yPos); lblBeamBolt.Size = new Size(labelWidth, 20); page.Controls.Add(lblBeamBolt); Label lblBottomOffset = new Label(); lblBottomOffset.Text = "底第一道螺栓离梁底高:"; lblBottomOffset.Location = new Point(column2, yPos); lblBottomOffset.Size = new Size(150, 20); page.Controls.Add(lblBottomOffset); txtBeamBoltBottomOffset = new TextBox(); txtBeamBoltBottomOffset.Text = "150"; txtBeamBoltBottomOffset.Location = new Point(column2 + 160, yPos); txtBeamBoltBottomOffset.Size = new Size(50, 20); page.Controls.Add(txtBeamBoltBottomOffset); Label lblTopOffset = new Label(); lblTopOffset.Text = "顶第一道螺栓离板底高:"; lblTopOffset.Location = new Point(column3, yPos); lblTopOffset.Size = new Size(150, 20); page.Controls.Add(lblTopOffset); txtBeamBoltTopOffset = new TextBox(); txtBeamBoltTopOffset.Text = "150"; txtBeamBoltTopOffset.Location = new Point(column3 + 160, yPos); txtBeamBoltTopOffset.Size = new Size(50, 20); page.Controls.Add(txtBeamBoltTopOffset); yPos += 30; Label lblMaxSpacing = new Label(); lblMaxSpacing.Text = "螺栓最大间距:"; lblMaxSpacing.Location = new Point(column2, yPos); lblMaxSpacing.Size = new Size(100, 20); page.Controls.Add(lblMaxSpacing); txtBeamBoltMaxSpacing = new TextBox(); txtBeamBoltMaxSpacing.Text = "500"; txtBeamBoltMaxSpacing.Location = new Point(column2 + 110, yPos); txtBeamBoltMaxSpacing.Size = new Size(50, 20); page.Controls.Add(txtBeamBoltMaxSpacing); yPos += 40; // 绘制梁底次龙骨 Label lblBeamBottomSecondary = new Label(); lblBeamBottomSecondary.Text = "绘制梁底次龙骨:"; lblBeamBottomSecondary.Location = new Point(column1, yPos); lblBeamBottomSecondary.Size = new Size(labelWidth, 20); page.Controls.Add(lblBeamBottomSecondary); radBeamBottomSecondaryYes = new RadioButton(); radBeamBottomSecondaryYes.Text = "是"; radBeamBottomSecondaryYes.Checked = true; radBeamBottomSecondaryYes.Location = new Point(column2, yPos); radBeamBottomSecondaryYes.Size = new Size(40, 20); page.Controls.Add(radBeamBottomSecondaryYes); radBeamBottomSecondaryNo = new RadioButton(); radBeamBottomSecondaryNo.Text = "否"; radBeamBottomSecondaryNo.Location = new Point(column2 + 50, yPos); radBeamBottomSecondaryNo.Size = new Size(40, 20); page.Controls.Add(radBeamBottomSecondaryNo); // 绘制方向 Label lblDirection3 = new Label(); lblDirection3.Text = "绘制方向:"; lblDirection3.Location = new Point(column3, yPos); lblDirection3.Size = new Size(70, 20); page.Controls.Add(lblDirection3); radBeamBottomSecondaryHorizontal = new RadioButton(); radBeamBottomSecondaryHorizontal.Text = "横向"; radBeamBottomSecondaryHorizontal.Location = new Point(column3 + 80, yPos); radBeamBottomSecondaryHorizontal.Size = new Size(50, 20); page.Controls.Add(radBeamBottomSecondaryHorizontal); radBeamBottomSecondaryLongitudinal = new RadioButton(); radBeamBottomSecondaryLongitudinal.Text = "纵向"; radBeamBottomSecondaryLongitudinal.Location = new Point(column3 + 140, yPos); radBeamBottomSecondaryLongitudinal.Size = new Size(50, 20); radBeamBottomSecondaryLongitudinal.Checked = true; page.Controls.Add(radBeamBottomSecondaryLongitudinal); // 材料 Label lblMaterial3 = new Label(); lblMaterial3.Text = "材料:"; lblMaterial3.Location = new Point(column4, yPos); lblMaterial3.Size = new Size(50, 20); page.Controls.Add(lblMaterial3); cmbBeamBottomSecondaryMaterial = new ComboBox(); cmbBeamBottomSecondaryMaterial.Items.AddRange(new object[] { "木方", "方钢", "钢管" }); cmbBeamBottomSecondaryMaterial.SelectedIndex = 0; cmbBeamBottomSecondaryMaterial.Location = new Point(column4 + 50, yPos); cmbBeamBottomSecondaryMaterial.Size = new Size(80, 20); page.Controls.Add(cmbBeamBottomSecondaryMaterial); yPos += 30; // 规格 Label lblSpec3 = new Label(); lblSpec3.Text = "规格:"; lblSpec3.Location = new Point(column2, yPos); lblSpec3.Size = new Size(40, 20); page.Controls.Add(lblSpec3); Label lblHeight3 = new Label(); lblHeight3.Text = "高:"; lblHeight3.Location = new Point(column2 + 50, yPos); lblHeight3.Size = new Size(30, 20); page.Controls.Add(lblHeight3); txtBeamBottomSecondaryHeight = new TextBox(); txtBeamBottomSecondaryHeight.Text = "90"; txtBeamBottomSecondaryHeight.Location = new Point(column2 + 80, yPos); txtBeamBottomSecondaryHeight.Size = new Size(50, 20); page.Controls.Add(txtBeamBottomSecondaryHeight); Label lblWidth3 = new Label(); lblWidth3.Text = "宽:"; lblWidth3.Location = new Point(column2 + 140, yPos); lblWidth3.Size = new Size(30, 20); page.Controls.Add(lblWidth3); txtBeamBottomSecondaryWidth = new TextBox(); txtBeamBottomSecondaryWidth.Text = "40"; txtBeamBottomSecondaryWidth.Location = new Point(column2 + 170, yPos); txtBeamBottomSecondaryWidth.Size = new Size(50, 20); page.Controls.Add(txtBeamBottomSecondaryWidth); Label lblSpacing3 = new Label(); lblSpacing3.Text = "间距:"; lblSpacing3.Location = new Point(column2 + 230, yPos); lblSpacing3.Size = new Size(40, 20); page.Controls.Add(lblSpacing3); txtBeamBottomSecondarySpacing = new TextBox(); txtBeamBottomSecondarySpacing.Text = "200"; txtBeamBottomSecondarySpacing.Location = new Point(column2 + 270, yPos); txtBeamBottomSecondarySpacing.Size = new Size(50, 20); page.Controls.Add(txtBeamBottomSecondarySpacing); yPos += 40; // 绘制梁底主龙骨 Label lblBeamBottomPrimary = new Label(); lblBeamBottomPrimary.Text = "绘制梁底主龙骨:"; lblBeamBottomPrimary.Location = new Point(column1, yPos); lblBeamBottomPrimary.Size = new Size(labelWidth, 20); page.Controls.Add(lblBeamBottomPrimary); radBeamBottomPrimaryYes = new RadioButton(); radBeamBottomPrimaryYes.Text = "是"; radBeamBottomPrimaryYes.Checked = true; radBeamBottomPrimaryYes.Location = new Point(column2, yPos); radBeamBottomPrimaryYes.Size = new Size(40, 20); page.Controls.Add(radBeamBottomPrimaryYes); radBeamBottomPrimaryNo = new RadioButton(); radBeamBottomPrimaryNo.Text = "否"; radBeamBottomPrimaryNo.Location = new Point(column2 + 50, yPos); radBeamBottomPrimaryNo.Size = new Size(40, 20); page.Controls.Add(radBeamBottomPrimaryNo); // 材料 Label lblMaterial4 = new Label(); lblMaterial4.Text = "材料:"; lblMaterial4.Location = new Point(column3, yPos); lblMaterial4.Size = new Size(50, 20); page.Controls.Add(lblMaterial4); cmbBeamBottomPrimaryMaterial = new ComboBox(); cmbBeamBottomPrimaryMaterial.Items.AddRange(new object[] { "木方", "方钢", "钢管" }); cmbBeamBottomPrimaryMaterial.SelectedIndex = 2; cmbBeamBottomPrimaryMaterial.Location = new Point(column3 + 50, yPos); cmbBeamBottomPrimaryMaterial.Size = new Size(80, 20); page.Controls.Add(cmbBeamBottomPrimaryMaterial); yPos += 30; // 规格 Label lblSpec4 = new Label(); lblSpec4.Text = "规格:"; lblSpec4.Location = new Point(column2, yPos); lblSpec4.Size = new Size(40, 20); page.Controls.Add(lblSpec4); Label lblHeight4 = new Label(); lblHeight4.Text = "高:"; lblHeight4.Location = new Point(column2 + 50, yPos); lblHeight4.Size = new Size(30, 20); page.Controls.Add(lblHeight4); txtBeamBottomPrimaryHeight = new TextBox(); txtBeamBottomPrimaryHeight.Text = "100"; txtBeamBottomPrimaryHeight.Location = new Point(column2 + 80, yPos); txtBeamBottomPrimaryHeight.Size = new Size(50, 20); page.Controls.Add(txtBeamBottomPrimaryHeight); Label lblWidth4 = new Label(); lblWidth4.Text = "宽:"; lblWidth4.Location = new Point(column2 + 140, yPos); lblWidth4.Size = new Size(30, 20); page.Controls.Add(lblWidth4); txtBeamBottomPrimaryWidth = new TextBox(); txtBeamBottomPrimaryWidth.Text = "100"; txtBeamBottomPrimaryWidth.Location = new Point(column2 + 170, yPos); txtBeamBottomPrimaryWidth.Size = new Size(50, 20); page.Controls.Add(txtBeamBottomPrimaryWidth); } private void InitializeSlabPage(TabPage page) { int yPos = 15; int labelWidth = 120; int controlSpacing = 10; int column1 = 20; int column2 = column1 + labelWidth + controlSpacing; int column3 = column2 + 100; int column4 = column3 + 100; // 标题 Label lblTitle = new Label(); lblTitle.Text = "板龙骨设置参数"; lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 10, System.Drawing.FontStyle.Bold); lblTitle.Location = new Point(column1, yPos); lblTitle.Size = new Size(200, 20); page.Controls.Add(lblTitle); yPos += 30; // 默认楼板厚和模板厚 Label lblDefaultSlab = new Label(); lblDefaultSlab.Text = "默认楼板厚:"; lblDefaultSlab.Location = new Point(column1, yPos); lblDefaultSlab.Size = new Size(90, 20); page.Controls.Add(lblDefaultSlab); txtDefaultSlabThickness = new TextBox(); txtDefaultSlabThickness.Text = "120"; txtDefaultSlabThickness.Location = new Point(column1 + 100, yPos); txtDefaultSlabThickness.Size = new Size(50, 20); page.Controls.Add(txtDefaultSlabThickness); Label lblFormwork = new Label(); lblFormwork.Text = "模板厚:"; lblFormwork.Location = new Point(column1 + 160, yPos); lblFormwork.Size = new Size(70, 20); page.Controls.Add(lblFormwork); txtFormworkThickness = new TextBox(); txtFormworkThickness.Text = "15"; txtFormworkThickness.Location = new Point(column1 + 230, yPos); txtFormworkThickness.Size = new Size(50, 20); page.Controls.Add(txtFormworkThickness); yPos += 40; // 绘制板底次龙骨 Label lblSlabSecondary = new Label(); lblSlabSecondary.Text = "绘制板底次龙骨:"; lblSlabSecondary.Location = new Point(column1, yPos); lblSlabSecondary.Size = new Size(labelWidth, 20); page.Controls.Add(lblSlabSecondary); radSlabSecondaryYes = new RadioButton(); radSlabSecondaryYes.Text = "是"; radSlabSecondaryYes.Checked = true; radSlabSecondaryYes.Location = new Point(column2, yPos); radSlabSecondaryYes.Size = new Size(40, 20); page.Controls.Add(radSlabSecondaryYes); radSlabSecondaryNo = new RadioButton(); radSlabSecondaryNo.Text = "否"; radSlabSecondaryNo.Location = new Point(column2 + 50, yPos); radSlabSecondaryNo.Size = new Size(40, 20); page.Controls.Add(radSlabSecondaryNo); // 绘制方向 Label lblDirection = new Label(); lblDirection.Text = "绘制方向:"; lblDirection.Location = new Point(column3, yPos); lblDirection.Size = new Size(70, 20); page.Controls.Add(lblDirection); radSlabSecondaryHorizontal = new RadioButton(); radSlabSecondaryHorizontal.Text = "横向"; radSlabSecondaryHorizontal.Location = new Point(column3 + 80, yPos); radSlabSecondaryHorizontal.Size = new Size(50, 20); page.Controls.Add(radSlabSecondaryHorizontal); radSlabSecondaryLongitudinal = new RadioButton(); radSlabSecondaryLongitudinal.Text = "纵向"; radSlabSecondaryLongitudinal.Location = new Point(column3 + 140, yPos); radSlabSecondaryLongitudinal.Size = new Size(50, 20); radSlabSecondaryLongitudinal.Checked = true; page.Controls.Add(radSlabSecondaryLongitudinal); // 材料 Label lblMaterial = new Label(); lblMaterial.Text = "材料:"; lblMaterial.Location = new Point(column4, yPos); lblMaterial.Size = new Size(50, 20); page.Controls.Add(lblMaterial); cmbSlabSecondaryMaterial = new ComboBox(); cmbSlabSecondaryMaterial.Items.AddRange(new object[] { "木方", "方钢", "钢管" }); cmbSlabSecondaryMaterial.SelectedIndex = 0; cmbSlabSecondaryMaterial.Location = new Point(column4 + 50, yPos); cmbSlabSecondaryMaterial.Size = new Size(80, 20); page.Controls.Add(cmbSlabSecondaryMaterial); yPos += 30; // 规格 Label lblSpec = new Label(); lblSpec.Text = "规格:"; lblSpec.Location = new Point(column2, yPos); lblSpec.Size = new Size(40, 20); page.Controls.Add(lblSpec); Label lblHeight = new Label(); lblHeight.Text = "高:"; lblHeight.Location = new Point(column2 + 50, yPos); lblHeight.Size = new Size(30, 20); page.Controls.Add(lblHeight); txtSlabSecondaryHeight = new TextBox(); txtSlabSecondaryHeight.Text = "90"; txtSlabSecondaryHeight.Location = new Point(column2 + 80, yPos); txtSlabSecondaryHeight.Size = new Size(50, 20); page.Controls.Add(txtSlabSecondaryHeight); Label lblWidth = new Label(); lblWidth.Text = "宽:"; lblWidth.Location = new Point(column2 + 140, yPos); lblWidth.Size = new Size(30, 20); page.Controls.Add(lblWidth); txtSlabSecondaryWidth = new TextBox(); txtSlabSecondaryWidth.Text = "40"; txtSlabSecondaryWidth.Location = new Point(column2 + 170, yPos); txtSlabSecondaryWidth.Size = new Size(50, 20); page.Controls.Add(txtSlabSecondaryWidth); Label lblSpacing = new Label(); lblSpacing.Text = "间距:"; lblSpacing.Location = new Point(column2 + 230, yPos); lblSpacing.Size = new Size(40, 20); page.Controls.Add(lblSpacing); txtSlabSecondarySpacing = new TextBox(); txtSlabSecondarySpacing.Text = "200"; txtSlabSecondarySpacing.Location = new Point(column2 + 270, yPos); txtSlabSecondarySpacing.Size = new Size(50, 20); page.Controls.Add(txtSlabSecondarySpacing); yPos += 40; // 绘制板底主龙骨 Label lblSlabPrimary = new Label(); lblSlabPrimary.Text = "绘制板底主龙骨:"; lblSlabPrimary.Location = new Point(column1, yPos); lblSlabPrimary.Size = new Size(labelWidth, 20); page.Controls.Add(lblSlabPrimary); radSlabPrimaryYes = new RadioButton(); radSlabPrimaryYes.Text = "是"; radSlabPrimaryYes.Checked = true; radSlabPrimaryYes.Location = new Point(column2, yPos); radSlabPrimaryYes.Size = new Size(40, 20); page.Controls.Add(radSlabPrimaryYes); radSlabPrimaryNo = new RadioButton(); radSlabPrimaryNo.Text = "否"; radSlabPrimaryNo.Location = new Point(column2 + 50, yPos); radSlabPrimaryNo.Size = new Size(40, 20); page.Controls.Add(radSlabPrimaryNo); // 材料 Label lblMaterial2 = new Label(); lblMaterial2.Text = "材料:"; lblMaterial2.Location = new Point(column3, yPos); lblMaterial2.Size = new Size(50, 20); page.Controls.Add(lblMaterial2); cmbSlabPrimaryMaterial = new ComboBox(); cmbSlabPrimaryMaterial.Items.AddRange(new object[] { "木方", "方钢", "钢管" }); cmbSlabPrimaryMaterial.SelectedIndex = 2; cmbSlabPrimaryMaterial.Location = new Point(column3 + 50, yPos); cmbSlabPrimaryMaterial.Size = new Size(80, 20); page.Controls.Add(cmbSlabPrimaryMaterial); yPos += 30; // 规格 Label lblSpec2 = new Label(); lblSpec2.Text = "规格:"; lblSpec2.Location = new Point(column2, yPos); lblSpec2.Size = new Size(40, 20); page.Controls.Add(lblSpec2); Label lblHeight2 = new Label(); lblHeight2.Text = "高:"; lblHeight2.Location = new Point(column2 + 50, yPos); lblHeight2.Size = new Size(30, 20); page.Controls.Add(lblHeight2); txtSlabPrimaryHeight = new TextBox(); txtSlabPrimaryHeight.Text = "100"; txtSlabPrimaryHeight.Location = new Point(column2 + 80, yPos); txtSlabPrimaryHeight.Size = new Size(50, 20); page.Controls.Add(txtSlabPrimaryHeight); Label lblWidth2 = new Label(); lblWidth2.Text = "宽:"; lblWidth2.Location = new Point(column2 + 140, yPos); lblWidth2.Size = new Size(30, 20); page.Controls.Add(lblWidth2); txtSlabPrimaryWidth = new TextBox(); txtSlabPrimaryWidth.Text = "100"; txtSlabPrimaryWidth.Location = new Point(column2 + 170, yPos); txtSlabPrimaryWidth.Size = new Size(50, 20); page.Controls.Add(txtSlabPrimaryWidth); } private void SetupEventHandlers() { // 设置事件处理器 radBeamSideSecondaryYes.CheckedChanged += (s, e) => { bool enabled = radBeamSideSecondaryYes.Checked; radBeamSideSecondaryHorizontal.Enabled = enabled; radBeamSideSecondaryVertical.Enabled = enabled; cmbBeamSideSecondaryMaterial.Enabled = enabled; txtBeamSideSecondaryHeight.Enabled = enabled; txtBeamSideSecondaryWidth.Enabled = enabled; txtBeamSideSecondarySpacing.Enabled = enabled; if (enabled) { UpdateBeamSideSecondaryControls(); } }; radBeamSideSecondaryNo.CheckedChanged += (s, e) => { bool enabled = !radBeamSideSecondaryNo.Checked; radBeamSideSecondaryHorizontal.Enabled = enabled; radBeamSideSecondaryVertical.Enabled = enabled; cmbBeamSideSecondaryMaterial.Enabled = enabled; txtBeamSideSecondaryHeight.Enabled = enabled; txtBeamSideSecondaryWidth.Enabled = enabled; txtBeamSideSecondarySpacing.Enabled = enabled; }; radBeamSideSecondaryHorizontal.CheckedChanged += (s, e) => UpdateBeamSideSecondaryControls(); radBeamSideSecondaryVertical.CheckedChanged += (s, e) => UpdateBeamSideSecondaryControls(); cmbBeamSideSecondaryMaterial.SelectedIndexChanged += (s, e) => UpdateBeamSideSecondaryControls(); // 其他事件处理器... } private void UpdateBeamSideSecondaryControls() { bool isEnabled = radBeamSideSecondaryYes.Checked; bool isHorizontal = radBeamSideSecondaryHorizontal.Checked; bool isVertical = radBeamSideSecondaryVertical.Checked; string material = cmbBeamSideSecondaryMaterial.Text; if (!isEnabled) { // 如果选择"否",禁用所有控件 radBeamSideSecondaryHorizontal.Enabled = false; radBeamSideSecondaryVertical.Enabled = false; cmbBeamSideSecondaryMaterial.Enabled = false; txtBeamSideSecondaryHeight.Enabled = false; txtBeamSideSecondaryWidth.Enabled = false; txtBeamSideSecondarySpacing.Enabled = false; return; } // 根据文档要求更新控件状态 if (isVertical) { txtBeamSideSecondaryHeight.Enabled = false; txtBeamSideSecondarySpacing.Enabled = false; txtBeamSideSecondaryWidth.Enabled = true; } else if (isHorizontal) { txtBeamSideSecondaryHeight.Enabled = true; txtBeamSideSecondarySpacing.Enabled = true; txtBeamSideSecondaryWidth.Enabled = true; } if (material == "钢管") { txtBeamSideSecondaryHeight.Enabled = false; txtBeamSideSecondaryWidth.Enabled = false; txtBeamSideSecondarySpacing.Enabled = false; } } protected override void OnFormClosing(FormClosingEventArgs e) { if (this.DialogResult == DialogResult.OK) { // 收集参数 Parameters.BeamSideSecondary.Enabled = radBeamSideSecondaryYes.Checked; Parameters.BeamSideSecondary.Direction = radBeamSideSecondaryHorizontal.Checked ? "Horizontal" : "Vertical"; Parameters.BeamSideSecondary.Material = cmbBeamSideSecondaryMaterial.Text; if (double.TryParse(txtBeamSideSecondaryHeight.Text, out double height)) Parameters.BeamSideSecondary.Height = height; if (double.TryParse(txtBeamSideSecondaryWidth.Text, out double width)) Parameters.BeamSideSecondary.Width = width; if (double.TryParse(txtBeamSideSecondarySpacing.Text, out double spacing)) Parameters.BeamSideSecondary.Spacing = spacing; // 收集其他参数... Parameters.DefaultSlabThickness = double.Parse(txtDefaultSlabThickness.Text); Parameters.FormworkThickness = double.Parse(txtFormworkThickness.Text); // 梁侧主龙骨参数 Parameters.BeamSidePrimary.Enabled = radBeamSidePrimaryYes.Checked; Parameters.BeamSidePrimary.Direction = radBeamSidePrimaryHorizontal.Checked ? "Horizontal" : "Vertical"; Parameters.BeamSidePrimary.Material = cmbBeamSidePrimaryMaterial.Text; if (double.TryParse(txtBeamSidePrimaryHeight.Text, out double primaryHeight)) Parameters.BeamSidePrimary.Height = primaryHeight; if (double.TryParse(txtBeamSidePrimaryWidth.Text, out double primaryWidth)) Parameters.BeamSidePrimary.Width = primaryWidth; if (double.TryParse(txtBeamSidePrimaryDiameter.Text, out double diameter)) Parameters.BeamSidePrimary.Diameter = diameter; // 梁对拉螺栓参数 if (double.TryParse(txtBeamBoltBottomOffset.Text, out double bottomOffset)) Parameters.BeamBolt.BottomOffset = bottomOffset; if (double.TryParse(txtBeamBoltTopOffset.Text, out double topOffset)) Parameters.BeamBolt.TopOffset = topOffset; if (double.TryParse(txtBeamBoltMaxSpacing.Text, out double maxSpacing)) Parameters.BeamBolt.MaxSpacing = maxSpacing; // 梁底次龙骨参数 Parameters.BeamBottomSecondary.Enabled = radBeamBottomSecondaryYes.Checked; Parameters.BeamBottomSecondary.Direction = radBeamBottomSecondaryLongitudinal.Checked ? "Longitudinal" : "Horizontal"; Parameters.BeamBottomSecondary.Material = cmbBeamBottomSecondaryMaterial.Text; if (double.TryParse(txtBeamBottomSecondaryHeight.Text, out double bottomSecondaryHeight)) Parameters.BeamBottomSecondary.Height = bottomSecondaryHeight; if (double.TryParse(txtBeamBottomSecondaryWidth.Text, out double bottomSecondaryWidth)) Parameters.BeamBottomSecondary.Width = bottomSecondaryWidth; if (double.TryParse(txtBeamBottomSecondarySpacing.Text, out double bottomSecondarySpacing)) Parameters.BeamBottomSecondary.Spacing = bottomSecondarySpacing; // 梁底主龙骨参数 Parameters.BeamBottomPrimary.Enabled = radBeamBottomPrimaryYes.Checked; Parameters.BeamBottomPrimary.Material = cmbBeamBottomPrimaryMaterial.Text; if (double.TryParse(txtBeamBottomPrimaryHeight.Text, out double bottomPrimaryHeight)) Parameters.BeamBottomPrimary.Height = bottomPrimaryHeight; if (double.TryParse(txtBeamBottomPrimaryWidth.Text, out double bottomPrimaryWidth)) Parameters.BeamBottomPrimary.Width = bottomPrimaryWidth; // 板底次龙骨参数 Parameters.Slab.SecondaryEnabled = radSlabSecondaryYes.Checked; Parameters.Slab.SecondaryDirection = radSlabSecondaryLongitudinal.Checked ? "Longitudinal" : "Horizontal"; Parameters.Slab.SecondaryMaterial = cmbSlabSecondaryMaterial.Text; if (double.TryParse(txtSlabSecondaryHeight.Text, out double slabSecondaryHeight)) Parameters.Slab.SecondaryHeight = slabSecondaryHeight; if (double.TryParse(txtSlabSecondaryWidth.Text, out double slabSecondaryWidth)) Parameters.Slab.SecondaryWidth = slabSecondaryWidth; if (double.TryParse(txtSlabSecondarySpacing.Text, out double slabSecondarySpacing)) Parameters.Slab.SecondarySpacing = slabSecondarySpacing; // 板底主龙骨参数 Parameters.Slab.PrimaryEnabled = radSlabPrimaryYes.Checked; Parameters.Slab.PrimaryMaterial = cmbSlabPrimaryMaterial.Text; if (double.TryParse(txtSlabPrimaryHeight.Text, out double slabPrimaryHeight)) Parameters.Slab.PrimaryHeight = slabPrimaryHeight; if (double.TryParse(txtSlabPrimaryWidth.Text, out double slabPrimaryWidth)) Parameters.Slab.PrimaryWidth = slabPrimaryWidth; } base.OnFormClosing(e); } } public class BeamSlabCommand { [CommandMethod("DB")] public void StartBeamSlab() { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; // 显示参数设置窗口 using (ParameterForm form = new ParameterForm()) { // 使用完全限定名解决Application歧义 if (Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(null, form, false) != DialogResult.OK) return; BeamSlabParameters parameters = form.Parameters; // 开始绘制循环 DrawBeamSlab(doc, ed, parameters); } } private void DrawBeamSlab(Document doc, Editor ed, BeamSlabParameters parameters) { Database db = doc.Database; List<Point3d> beamPoints = new List<Point3d>(); List<double> beamHeights = new List<double>(); List<double> slabThicknesses = new List<double>(); while (true) { // 1. 获取梁的第一点 PromptPointResult ppr1 = ed.GetPoint("\n请点击梁的第一点: "); if (ppr1.Status != PromptStatus.OK) break; // 2. 获取梁的第二点 PromptPointResult ppr2 = ed.GetPoint("\n请点击梁的第二点: "); if (ppr2.Status != PromptStatus.OK) break; // 3. 获取梁高 PromptDoubleOptions pdoHeight = new PromptDoubleOptions("\n请输入梁高(mm): "); pdoHeight.AllowNegative = false; pdoHeight.DefaultValue = 500; // 默认梁高500mm PromptDoubleResult pdrHeight = ed.GetDouble(pdoHeight); if (pdrHeight.Status != PromptStatus.OK) break; double beamHeight = pdrHeight.Value; // 4. 获取板厚或升降板信息 double slabThickness = GetSlabThickness(ed, parameters.DefaultSlabThickness); if (double.IsNaN(slabThickness)) break; beamPoints.Add(ppr1.Value); beamPoints.Add(ppr2.Value); beamHeights.Add(beamHeight); slabThicknesses.Add(slabThickness); // 绘制梁和板 using (Transaction tr = db.TransactionManager.StartTransaction()) { DrawBeamAndSlab(tr, db, ppr1.Value, ppr2.Value, beamHeight, slabThickness, parameters); tr.Commit(); } } // 完成绘制,闭合区域并填充 if (beamPoints.Count >= 4) { using (Transaction tr = db.TransactionManager.StartTransaction()) { CompleteDrawing(tr, db, beamPoints, beamHeights, slabThicknesses, parameters); tr.Commit(); } } } private double GetSlabThickness(Editor ed, double defaultThickness) { PromptKeywordOptions pko = new PromptKeywordOptions("\n请输入[板厚(A)/升降板(S)]: "); pko.Keywords.Add("A"); pko.Keywords.Add("S"); pko.Keywords.Default = "A"; PromptResult pr = ed.GetKeywords(pko); if (pr.Status != PromptStatus.OK) return double.NaN; if (pr.StringResult == "A") { PromptDoubleOptions pdo = new PromptDoubleOptions("\n输入板厚(mm): "); pdo.DefaultValue = defaultThickness; pdo.AllowNegative = false; PromptDoubleResult pdr = ed.GetDouble(pdo); if (pdr.Status != PromptStatus.OK) return double.NaN; return pdr.Value; } else // "S" { PromptDoubleOptions pdo = new PromptDoubleOptions("\n请输入升降板高度(升板为正数,降板为负数)mm: "); pdo.AllowNegative = true; PromptDoubleResult pdr = ed.GetDouble(pdo); if (pdr.Status != PromptStatus.OK) return double.NaN; return pdr.Value; } } private void DrawBeamAndSlab(Transaction tr, Database db, Point3d pt1, Point3d pt2, double beamHeight, double slabThickness, BeamSlabParameters parameters) { // 计算偏移量 double offset = beamHeight - slabThickness; // 绘制梁的双线 Vector3d direction = (pt2 - pt1).GetNormal(); Vector3d perpendicular = direction.GetPerpendicularVector(); double halfFormwork = parameters.FormworkThickness / 2; Point3d innerPt1 = pt1 + perpendicular * halfFormwork; Point3d innerPt2 = pt2 + perpendicular * halfFormwork; Point3d outerPt1 = pt1 - perpendicular * halfFormwork; Point3d outerPt2 = pt2 - perpendicular * halfFormwork; // 创建梁的双线 Polyline beamInner = CreatePolyline(new[] { innerPt1, innerPt2 }); Polyline beamOuter = CreatePolyline(new[] { outerPt1, outerPt2 }); // 添加到数据库 AddToModelSpace(tr, db, beamInner); AddToModelSpace(tr, db, beamOuter); // 绘制竖向梁线 Vector3d verticalOffset = new Vector3d(0, 0, -offset); Polyline vertical1 = CreatePolyline(new[] { innerPt1, innerPt1 + verticalOffset }); Polyline vertical2 = CreatePolyline(new[] { innerPt2, innerPt2 + verticalOffset }); AddToModelSpace(tr, db, vertical1); AddToModelSpace(tr, db, vertical2); // 绘制板底线 Point3d slabPt1 = innerPt1 + verticalOffset; Point3d slabPt2 = innerPt2 + verticalOffset; Polyline slabLine = CreatePolyline(new[] { slabPt1, slabPt2 }); AddToModelSpace(tr, db, slabLine); // 根据参数绘制龙骨和对拉螺栓 if (parameters.BeamSideSecondary.Enabled) DrawBeamSideSecondary(tr, db, innerPt1, innerPt2, verticalOffset, parameters.BeamSideSecondary); if (parameters.BeamSidePrimary.Enabled) DrawBeamSidePrimary(tr, db, innerPt1, innerPt2, verticalOffset, parameters.BeamSidePrimary); if (parameters.BeamBolt.Enabled) DrawBeamBolts(tr, db, innerPt1, innerPt2, verticalOffset, parameters.BeamBolt); } private void DrawBeamSideSecondary(Transaction tr, Database db, Point3d pt1, Point3d pt2, Vector3d verticalOffset, BeamSideSecondaryParameters parameters) { // 根据参数绘制梁侧次龙骨 if (parameters.Direction == "Horizontal") { // 水平布置 double spacing = parameters.Spacing; double distance = pt1.DistanceTo(pt2); int count = (int)(distance / spacing); for (int i = 0; i <= count; i++) { double ratio = (double)i / count; Point3d position = pt1 + (pt2 - pt1) * ratio; // 绘制矩形木方或方钢 DrawTimberOrSteel(tr, db, position, verticalOffset, parameters.Material, parameters.Height, parameters.Width); } } else { // 竖向布置 Point3d start = pt1 + (pt2 - pt1) / 2; // 中间位置 DrawVerticalTimberOrSteel(tr, db, start, verticalOffset, parameters.Material, parameters.Width); } } private void DrawBeamSidePrimary(Transaction tr, Database db, Point3d pt1, Point3d pt2, Vector3d verticalOffset, BeamSidePrimaryParameters parameters) { // 实现梁侧主龙骨绘制逻辑 // 根据参数绘制梁侧主龙骨 // 这里需要根据实际需求实现 } private void DrawBeamBolts(Transaction tr, Database db, Point3d pt1, Point3d pt2, Vector3d verticalOffset, BeamBoltParameters parameters) { // 实现对拉螺栓绘制逻辑 // 根据参数绘制对拉螺栓 // 这里需要根据实际需求实现 } private void DrawTimberOrSteel(Transaction tr, Database db, Point3d position, Vector3d verticalOffset, string material, double height, double width) { // 根据材料类型绘制木方或方钢 if (material == "木方") { // 绘制木方矩形并填充 Polyline timber = CreateRectangle(position, width, height); AddToModelSpace(tr, db, timber); // 填充木方图案 Hatch hatch = CreateHatch(timber, "AHSI36", 100); AddToModelSpace(tr, db, hatch); } else if (material == "方钢" || material == "钢管") { // 绘制方钢或钢管(双线) double thickness = material == "方钢" ? 3 : 1.5; // 方钢壁厚3mm,钢管壁厚1.5mm DrawHollowSection(tr, db, position, width, height, thickness); } } private void DrawVerticalTimberOrSteel(Transaction tr, Database db, Point3d position, Vector3d verticalOffset, string material, double width) { // 实现竖向木方或方钢绘制逻辑 // 这里需要根据实际需求实现 } private void DrawHollowSection(Transaction tr, Database db, Point3d position, double width, double height, double thickness) { // 实现空心截面绘制逻辑 // 这里需要根据实际需求实现 } private void CompleteDrawing(Transaction tr, Database db, List<Point3d> beamPoints, List<double> beamHeights, List<double> slabThicknesses, BeamSlabParameters parameters) { // 创建闭合多段线框 Polyline boundary = new Polyline(); // 添加所有点形成闭合区域 for (int i = 0; i < beamPoints.Count; i++) { Point3d point = beamPoints[i]; boundary.AddVertexAt(i, new Point2d(point.X, point.Y), 0, 0, 0); } boundary.Closed = true; AddToModelSpace(tr, db, boundary); // 填充区域 Hatch hatch = CreateHatch(boundary, "AR-SAND", 100); AddToModelSpace(tr, db, hatch); } private Polyline CreatePolyline(Point3d[] points) { Polyline pl = new Polyline(); for (int i = 0; i < points.Length; i++) { pl.AddVertexAt(i, new Point2d(points[i].X, points[i].Y), 0, 0, 0); } return pl; } private Polyline CreateRectangle(Point3d center, double width, double height) { double halfWidth = width / 2; double halfHeight = height / 2; Polyline rect = new Polyline(); rect.AddVertexAt(0, new Point2d(center.X - halfWidth, center.Y - halfHeight), 0, 0, 0); rect.AddVertexAt(1, new Point2d(center.X + halfWidth, center.Y - halfHeight), 0, 0, 0); rect.AddVertexAt(2, new Point2d(center.X + halfWidth, center.Y + halfHeight), 0, 0, 0); rect.AddVertexAt(3, new Point2d(center.X - halfWidth, center.Y + halfHeight), 0, 0, 0); rect.Closed = true; return rect; } private Hatch CreateHatch(Polyline boundary, string patternName, double scale) { Hatch hatch = new Hatch(); hatch.SetHatchPattern(HatchPatternType.PreDefined, patternName); hatch.PatternScale = scale; hatch.Associative = true; ObjectIdCollection boundaries = new ObjectIdCollection(); boundaries.Add(boundary.ObjectId); hatch.AppendLoop(HatchLoopTypes.Outermost, boundaries); return hatch; } private void AddToModelSpace(Transaction tr, Database db, Entity entity) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); btr.AppendEntity(entity); tr.AddNewlyCreatedDBObject(entity, true); } } } 参数设置窗口界面显示不完整比例失衡
最新发布
08-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值