linux中设置PATH中点的说明 PATH=.:$PATH

本文解释了在设置环境变量PATH时,“.:”的作用。通过实际测试,揭示了它如何使用户能够在任意目录下直接运行当前目录中的可执行文件,无需添加前置'./'。

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

PATH=.:$PATH

在设置环境变量的时候,遇到一个问题,上面的“.:”的作用是什么,百思不得其解。经过测试终于发现。


在一个目录下,如果执行可执行文件,则命令如下:


hf@hf-desktop:~$ ll |grep btest
-rwxr-xr-x  1 hf   hf    7098 2012-10-28 22:08 btest*
hf@hf-desktop:~$ ./btest

^C
如果PATH设置如上,则可以直接输入

hf@hf-desktop:~$ ll |grep btest
-rwxr-xr-x  1 hf   hf    7098 2012-10-28 22:08 btest*
hf@hf-desktop:~$ btest

^C
表示无论你在哪个目录,都会把当前的目录作为可执行程序的搜索路径之一。而无需再输入“./”









staPoseArrs = np.asarray(staPoseArrList) # 总体RMS误差 errRmsAll = np.linalg.norm(staPoseArrs[:, :, :3] - pointsRT[:, np.newaxis, :3], axis=2).flatten() # 各点的平均偏差 absBiasArr = np.linalg.norm(pointsRT - staPosAvg, axis=1) # 3D RMS精度 rmsBias = np.sqrt(np.vdot(absBiasArr, absBiasArr) / len(absBiasArr)) # 3D RMS Accuracy # 各点的重复性误差和RMS误差 errReps = np.zeros(n) # points RMS Repeatability errRMSs = np.zeros(n) # points RMS for i in range(n): errRepOne = 0 errRmsOne = 0 m = len(staPoseArrList[i]) for staPose in staPoseArrList[i]: # 计算与平均位置的偏差(重复性) errRepOne += pow(np.linalg.norm(staPose[:3] - staPosAvg[i]), 2) # 计算与参考位置的偏差(精度) errRmsOne += pow(np.linalg.norm(staPose[:3] - pointsRT[i]), 2) errReps[i] = np.sqrt(errRepOne / m) errRMSs[i] = np.sqrt(errRmsOne / m) # 综合误差指标 rmsRep = np.sqrt(np.vdot(errReps, errReps) / n) # 3D RMS Repeatability #3D RMS重复性 absRMS = np.sqrt(np.vdot(errRMSs, errRMSs) / n) # 3D RMS #3D RMS 精度 rmsMax = np.max(errRMSs) #最大误差 rms99CI = np.quantile(errRMSs, 0.95) #95%置信区间 rmsMed = np.median(errRMSs) #中值误差 errResult = ("error[mm]: bias={:.2f}, rep={:.2f}, rms={:.2f}, rmsMax={:.2f}, 95%CI={:.2f}, median={:.2f}" .format(rmsBias, rmsRep, absRMS, rmsMax, rms99CI, rmsMed)) print(errResult) # 5. 计算方向误差 m = staPoseArrs.shape[1] staPoseArrsFlat = np.vstack([staPoseArrs[:, mi, :] for mi in range(m)]) errOriArr = np.std(staPoseArrsFlat[:, 3: 6], axis=0) errOri = np.linalg.norm(errOriArr) * 180 / np.pi print("ori std={:.2f}[deg]".format(errOri)) # 6. 保留中间数据 if boolSave: pointsXYRms = np.zeros((16, 3), dtype=float) for i in range(n): pointsXYRms[i] = staPosAvg[i] pointsXYRms[i, 2] = errRMSs[i] pointsPd = pd.DataFrame(pointsXYRms) outFile = fileDir + ".txt" pointsPd.to_csv(path_or_buf=outFile, sep=',', index=False, header=False) 这段代码是pdvMeas函数中生成这些参数的部分
07-30
PS C:\Users\Administrator> # CurlTools.psm1 >> # ============== >> # 修复函数导出问题的模块代码 >> >> # 模块初始化块 >> $script:Config = $null >> $script:CurlPath = $null >> $script:ConfigDir = $null >> $script:ConfigPath = $null >> $script:ModuleInitialized = $false >> >> # 检测操作系统 >> function Get-Platform { >> if ($PSVersionTable.PSEdition -eq "Core") { >> if ($IsWindows) { "Windows" } >> elseif ($IsLinux) { "Linux" } >> elseif ($IsMacOS) { "macOS" } >> } else { >> if ($env:OS -like "Windows*") { "Windows" } >> elseif (Test-Path "/etc/os-release") { "Linux" } >> else { "macOS" } >> } >> } >> >> # 获取配置目录 >> function Get-ConfigDir { >> $platform = Get-Platform >> switch ($platform) { >> "Linux" { "$HOME/.config/curltools" } >> "macOS" { "$HOME/Library/Application Support/CurlTools" } >> default { "$env:APPDATA\CurlTools" } >> } >> } >> >> # 核心初始化函数 >> function Initialize-Module { >> try { >> # 设置配置目录 >> $script:ConfigDir = Get-ConfigDir >> if (-not (Test-Path $script:ConfigDir)) { >> New-Item -ItemType Directory -Path $script:ConfigDir -Force | Out-Null >> } >> $script:ConfigPath = Join-Path $script:ConfigDir "config.json" >> >> # 加载或创建配置 >> if (Test-Path $script:ConfigPath) { >> $script:Config = Get-Content $script:ConfigPath | ConvertFrom-Json >> } >> >> if (-not $script:Config) { >> $script:Config = [PSCustomObject]@{ >> CurlPath = $null >> LastUpdate = (Get-Date).ToString("o") >> AutoUpdate = $true >> } >> } >> >> # 查找或安装curl >> if (-not $script:Config.CurlPath -or -not (Test-Path $script:Config.CurlPath)) { >> $script:Config.CurlPath = Find-CurlPath >> } >> >> # 保存配置 >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> $script:CurlPath = $script:Config.CurlPath >> $script:ModuleInitialized = $true >> >> return $true >> } catch { >> Write-Warning "模块初始化失败: $_" >> return $false >> } >> } >> >> # 查找curl路径 >> function Find-CurlPath { >> $platform = Get-Platform >> $exeName = if ($platform -eq "Windows") { "curl.exe" } else { "curl" } >> >> # 检查系统PATH >> $pathCurl = Get-Command $exeName -ErrorAction SilentlyContinue >> if ($pathCurl) { >> return $pathCurl.Source | Split-Path >> } >> >> # 平台特定路径 >> $searchPaths = switch ($platform) { >> "Windows" { >> @( >> "C:\Windows\System32", >> "C:\Program Files\curl\bin", >> "${env:ProgramFiles}\Git\usr\bin" >> ) >> } >> "Linux" { @("/usr/bin", "/usr/local/bin") } >> "macOS" { @("/usr/local/bin", "/opt/homebrew/bin") } >> } >> >> foreach ($path in $searchPaths) { >> $fullPath = Join-Path $path $exeName >> if (Test-Path $fullPath) { >> return $path >> } >> } >> >> # 终极方案:自动安装 >> return Install-Curl >> } >> >> # curl安装函数 >> function Install-Curl { >> $platform = Get-Platform >> try { >> if ($platform -eq "Windows") { >> $tempDir = [System.IO.Path]::GetTempPath() >> $curlZip = Join-Path $tempDir "curl.zip" >> $curlUrl = "https://curl.se/windows/dl-8.8.0_5/curl-8.8.0_5-win64-mingw.zip" >> >> # 使用安全下载函数 >> Invoke-SecureDownload -Url $curlUrl -OutputPath $curlZip >> >> Expand-Archive $curlZip -DestinationPath $tempDir -Force >> return Join-Path $tempDir "curl-8.8.0_5-win64-mingw\bin" >> } >> else { >> if ($platform -eq "Linux") { >> if (Get-Command apt -ErrorAction SilentlyContinue) { >> Start-Process -Wait -FilePath "sudo" -ArgumentList "apt", "update" >> Start-Process -Wait -FilePath "sudo" -ArgumentList "apt", "install", "-y", "curl" >> } elseif (Get-Command yum -ErrorAction SilentlyContinue) { >> Start-Process -Wait -FilePath "sudo" -ArgumentList "yum", "install", "-y", "curl" >> } >> return "/usr/bin" >> } >> else { >> if (-not (Get-Command brew -ErrorAction SilentlyContinue)) { >> # 使用安全下载安装Homebrew >> $installScript = Join-Path $env:TEMP "brew_install.sh" >> Invoke-SecureDownload -Url "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh" -OutputPath $installScript >> & "/bin/bash" $installScript >> } >> Start-Process -Wait -FilePath "brew" -ArgumentList "install", "curl" >> return "/usr/local/bin" >> } >> } >> } catch { >> throw "无法自动安装curl: $_" >> } >> } >> >> # ========== 公共函数 ========== >> function Get-CurlPath { >> Ensure-ModuleInitialized >> return $script:CurlPath >> } >> >> function Set-CurlPath { >> param( >> [Parameter(Mandatory=$true)] >> [ValidateScript({Test-Path $_})] >> [string]$Path >> ) >> >> Ensure-ModuleInitialized >> $script:CurlPath = $Path >> $script:Config.CurlPath = $Path >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> Write-Host "已设置curl路径: $Path" -ForegroundColor Green >> } >> >> function Get-CurlVersion { >> Ensure-ModuleInitialized >> $exe = if ((Get-Platform) -eq "Windows") { "curl.exe" } else { "curl" } >> $curlExe = Join-Path $script:CurlPath $exe >> & $curlExe --version | Select-Object -First 1 >> } >> >> function Invoke-SecureDownload { >> param( >> [Parameter(Mandatory=$true)] >> [string]$Url, >> >> [Parameter(Mandatory=$true)] >> [string]$OutputPath, >> >> [string]$ExpectedHash, >> [string]$HashAlgorithm = "SHA256" >> ) >> >> try { >> Write-Verbose "下载文件: $Url" >> $ProgressPreference = 'SilentlyContinue' >> >> # 创建输出目录(如果不存在) >> $outputDir = [System.IO.Path]::GetDirectoryName($OutputPath) >> if (-not [string]::IsNullOrWhiteSpace($outputDir) -and -not (Test-Path $outputDir)) { >> New-Item -ItemType Directory -Path $outputDir -Force | Out-Null >> } >> >> # 下载文件 >> Invoke-WebRequest -Uri $Url -OutFile $OutputPath -UseBasicParsing -ErrorAction Stop >> >> # 验证文件是否成功下载 >> if (-not (Test-Path $OutputPath)) { >> throw "文件下载后未找到: $OutputPath" >> } >> >> # 验证哈希(如果提供) >> if (-not [string]::IsNullOrWhiteSpace($ExpectedHash)) { >> $actualHash = (Get-FileHash -Path $OutputPath -Algorithm $HashAlgorithm).Hash >> if ($actualHash -ne $ExpectedHash) { >> Remove-Item -Path $OutputPath -Force >> throw "文件哈希不匹配! 期望: $ExpectedHash, 实际: $actualHash" >> } >> } >> >> return $OutputPath >> } catch { >> # 清理部分下载的文件 >> if (Test-Path $OutputPath) { >> Remove-Item -Path $OutputPath -Force -ErrorAction SilentlyContinue >> } >> throw "下载失败: $($_.Exception.Message)" >> } >> } >> >> # ========== 辅助函数 ========== >> function Ensure-ModuleInitialized { >> if (-not $script:ModuleInitialized) { >> if (-not (Initialize-Module)) { >> throw "模块未正确初始化" >> } >> } >> } >> >> # ========== 模块初始化 ========== >> # 尝试初始化但不强制 >> try { >> Initialize-Module | Out-Null >> Write-Host "CurlTools 模块初始化成功" -ForegroundColor Green >> } catch { >> Write-Warning "模块初始化错误: $_" >> } >> >> # ========== 函数导出 ========== >> # 显式导出公共函数 >> Export-ModuleMember -Function Get-CurlPath, Set-CurlPath, Get-CurlVersion, Invoke-SecureDownload >> CurlTools 模块初始化成功 Export-ModuleMember : 只能从模块内调用 Export-ModuleMember cmdlet。 所在位置 行:247 字符: 1 + Export-ModuleMember -Function Get-CurlPath, Set-CurlPath, Get-CurlVer ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (:) [Export-ModuleMember], InvalidOperationException + FullyQualifiedErrorId : Modules_CanOnlyExecuteExportModuleMemberInsideAModule,Microsoft.PowerShell.Commands.Expo rtModuleMemberCommand PS C:\Users\Administrator> $moduleDir = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\CurlTools" >> $modulePath = "$moduleDir\CurlTools.psm1" >> >> # 保存修复后的模块代码 >> Set-Content -Path $modulePath -Value $fixedModuleCode -Force >> PS C:\Users\Administrator> $manifest = @" >> @{ >> ModuleVersion = '1.2.0' >> RootModule = 'CurlTools.psm1' >> FunctionsToExport = @( >> 'Get-CurlPath', >> 'Set-CurlPath', >> 'Get-CurlVersion', >> 'Invoke-SecureDownload' >> ) >> CompatiblePSEditions = @('Desktop', 'Core') >> GUID = 'c0d1b1e1-1a2b-4c3d-8e4f-9a0b1c2d3e4f' >> Author = 'Your Name' >> Description = 'Powerful curl tools for PowerShell' >> } >> "@ >> >> Set-Content -Path "$moduleDir\CurlTools.psd1" -Value $manifest >> PS C:\Users\Administrator> PS C:\Users\Administrator> # 强制重新加载模块 >> Remove-Module CurlTools -ErrorAction SilentlyContinue >> Import-Module CurlTools -Force -Verbose >> >> # 验证函数是否可用 >> Get-Command -Module CurlTools >> >> # 测试所有功能 >> $curlPath = Get-CurlPath >> $curlVersion = Get-CurlVersion >> Write-Host "Curl 路径: $curlPath" -ForegroundColor Green >> Write-Host "Curl 版本: $curlVersion" -ForegroundColor Green >> >> # 测试下载功能 >> $testUrl = "https://raw.githubusercontent.com/PowerShell/PowerShell/master/README.md" >> $outputPath = "$env:TEMP\PowerShell_README.md" >> Invoke-SecureDownload -Url $testUrl -OutputPath $outputPath >> 详细信息: 正在从路径“C:\Users\Administrator\Documents\WindowsPowerShell\Modules\CurlTools\CurlTools.psd1”加载模块。 详细信息: 正在从路径“C:\Users\Administrator\Documents\WindowsPowerShell\Modules\CurlTools\CurlTools.psm1”加载模块。 Curl 路径: E:\curl-8.15.0_4-win64-mingw\bin Curl 版本: curl 8.15.0 (x86_64-w64-mingw32) libcurl/8.15.0 LibreSSL/4.1.0 zlib/1.3.1.zlib-ng brotli/1.1.0 zstd/1.5.7 WinIDN libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.66.0 ngtcp2/1.14.0 nghttp3/1.11.0 E:\ai_temp\PowerShell_README.md PS C:\Users\Administrator>
08-13
class DoubleLineEdge extends BaseEdge { protected getKeyPath(attributes) { // 获取源节点和目标节点 const { sourceNode, targetNode } = this; const [x1, y1] = sourceNode.getPosition(); const [x2, y2] = targetNode.getPosition(); // 获取边数据配置 const edgeData = this.context.graph.getEdgeData(this.id); const lineCount = edgeData.lineCount || 3; const spacing = edgeData.spacing || 8; // 计算方向向量 const dx = x2 - x1; const dy = y2 - y1; const length = Math.sqrt(dx * dx + dy * dy); const unitPerpendicularX = dy / length; const unitPerpendicularY = -dx / length; // 修复1:返回单一路径字符串(非对象数组) let path = ''; for (let i = 0; i < lineCount; i++) { const offset = (i - (lineCount - 1) / 2) * spacing; const startX = x1 + unitPerpendicularX * offset; const startY = y1 + unitPerpendicularY * offset; const endX = x2 + unitPerpendicularX * offset; const endY = y2 + unitPerpendicularY * offset; // 修复2:使用SVG路径字符串格式 if (i > 0) path += ' '; // 多条线用空格分隔 path += `M ${startX},${startY} L ${endX},${endY}`; } // 计算中点位置 const midX = (x1 + x2) / 2; const midY = (y1 + y2) / 2; // 获取图片配置 const imgCfg = edgeData.image || { url: 'default-icon.png', width: 20, height: 20 }; return path,{ x: midX - imgCfg.width / 2, y: midY - imgCfg.height / 2, width: imgCfg.width, height: imgCfg.height, img: imgCfg.url, zIndex: 10 }; } } 修改return path,{ x: midX - imgCfg.width / 2, y: midY - imgCfg.height / 2, width: imgCfg.width, height: imgCfg.height, img: imgCfg.url, zIndex: 10 }; }部分代码,使其可以在页面渲染
最新发布
08-16
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值