明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 872|回复: 8

[讨论] [效率提高]如何提高数据的分析处理

[复制链接]
发表于 2022-9-17 10:48:32 | 显示全部楼层 |阅读模式
cad有系统变量和环境变量.
当我们得到环境变量的文本后,可以用程序来判断哪些是系统存在的系统变量,我写了一个,效率低下.需要60s才能运行完,看哪位大侠优化下代码.
(defun c:tt (/ dat_file data date1 ff)
                                        ;以下文件由用户选择
  (setq        dat_file (getfiled "选择文件"
                           "E:/program/cad2014/AutoCAD 2014/"
                           "txt"
                           2
                 )
  )
  (setq ff (open dat_file "r"))
  (setq date1 (getvar "millisecs"))
  (setq lst nil)
  (setq data (read-line ff))

  (while data
    (if        (getenv data)
      (setq lst (cons data lst))
    )
    (setq data (read-line ff))
  )
  (close ff)


  (prompt (strcat "\总共耗时:"

                  (rtos        (/ (- (getvar "millisecs") date1)
                           1000.000
                        )
                        2
                        3
                  )
                  "\"秒。"
          )
  )
  (prin1)
)


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2022-9-17 11:12:00 | 显示全部楼层
这里面很多只有一个字母的,还有空格,你把文件内容转成表,排除单个字母的,排除重复的,排除空格,再去getenv
 楼主| 发表于 2022-9-17 11:31:06 | 显示全部楼层
菜卷鱼 发表于 2022-9-17 11:12
这里面很多只有一个字母的,还有空格,你把文件内容转成表,排除单个字母的,排除重复的,排除空格,再去ge ...

您说的有道理.我试试看.
 楼主| 发表于 2022-10-4 22:50:38 | 显示全部楼层
本帖最后由 tigcat 于 2022-10-4 23:25 编辑

过了一段时间再回头看这个问题,我想lisp处理文本数据可能比较麻烦,不能实现提速的目标,从而转变思路,觉得在文本处理中先想办法清除空格的,重复的文本,再利用lisp来判别可能更行之有效。

我把原来的附件中的文本执行了3个操作:
用文本编辑器执行了
1/删除空白行(费时较长,可能也是好几十秒,不过这个费时长比在lisp中感觉要好,起码知道它没卡死,lisp等分把钟都怀疑是卡死了;
2/删除重复行,很快完成
3/将一个字母一行的替换成空白行,再执行一遍删除空白行,这是操作失误,应该先执行操作3,再执行操作1的.
经过这样处理后,数据变成了29000多行,原数据是160.6万行。执行lisp耗时5秒左右。
最后主要的时间都用在处理文本上了,lisp耗时倒不算多了。

发表于 2022-10-5 14:46:34 | 显示全部楼层
tigcat 发表于 2022-10-4 22:50
过了一段时间再回头看这个问题,我想lisp处理文本数据可能比较麻烦,不能实现提速的目标,从而转变思路,觉得 ...

我在我们公司做了一个ERP离线库读取,库文件就是txt,12M大的文件,目前是12万多行,读取速度很快,几乎感觉不到停顿
 楼主| 发表于 2022-10-5 15:04:26 | 显示全部楼层
菜卷鱼 发表于 2022-10-5 14:46
我在我们公司做了一个ERP离线库读取,库文件就是txt,12M大的文件,目前是12万多行,读取速度很快,几乎 ...

您这个读取效率高
发表于 2022-10-5 15:09:50 | 显示全部楼层
tigcat 发表于 2022-10-5 15:04
您这个读取效率高

确实应该在txt里面先处理一下
发表于 2022-10-5 21:54:18 | 显示全部楼层
tigcat 发表于 2022-10-4 22:50
过了一段时间再回头看这个问题,我想lisp处理文本数据可能比较麻烦,不能实现提速的目标,从而转变思路,觉得 ...

朋友  你处理完后 得到多少个变量  我按你的方法弄了   得到了500多个字符串 是不是这些值?
("2D Model grid axis lines color" "2D Model grid axis lines tint" "2D Model grid major lines color" "2D Model grid major lines tint" "2D Model grid minor lines color" "2D Model grid minor lines tint" "2D Model viewport control color" "3DCONVERSIONMODE" "3DSELECTIONMODE" "ACAD" "ACADCFG" "ACADDRV" "ACADHELP" "ACADLOGFILE" "ACADLspAsDoc" "ACADSUPPORT" "ARXDemandLoad" "AUTOMATICPUB" "AVEMAPS" "ActRecPath" "ActUI" "ActiveAssistance" "AlarmOnError" "AnnoAutoScale" "AnnoAutoScaleLayout" "Anyport" "AppData" "AppStatusBarUseIcons" "AssignInsertUnits" "Attdia" "Attipe" "Attmulti" "Attreq" "AuditControlFlags" "AutoSaveFile" "AutoSnapColor" "AutoSnapControl" "AutoSnapPolarAddAng" "AutoSnapPolarDistance" "AutoSnapShowAperture" "AutoSnapSize" "AutoSnapTrackPath" "AutomaticPlotLog" "AutomaticSaveMinutes" "Autotracking vector" "BACTIONBARMODE" "BActionColor" "BDependencyHighlight" "BEdit 3d AutoSnap Color" "BEdit ATrack use tint" "BEdit ATrack vector" "BEdit AutoSnap Color" "BEdit Dynamic Dimension Line color" "BEdit Web color" "BEdit Web shape color" "BEdit Web(missing file) color" "BEdit Xhair color" "BEdit Xhair use tint" "BEdit bk color" "BEdit bk use tint" "BEdit color" "BEdit contour color" "BEdit end color" "BEdit falloff color" "BEdit glyphs color" "BEdit grid axis lines color" "BEdit grid axis lines tint" "BEdit grid major lines color" "BEdit grid major lines tint" "BEdit grid minor lines color" "BEdit grid minor lines tint" "BEdit hotspot color" "BEdit lux at distance color" "BEdit start color" "BEditBackground" "BGRDPLOTTIMEOUT" "BGripObjColor" "BLOCKEDITLOCK" "BParameterColor" "BParameterFont" "BTMarkDisplay" "Background" "BackgroundPlot" "BeditFullyConstrainedClr" "BeditOverConstrainedClr" "BeditPartialConstrainedClr" "BeditUnconstrainedClr" "Blipmode" "BmpOutCompression" "BvMode" "CAPTURETHUMBNAILS" "CENTERMT" "CLIInit" "COMSPEC" "CROSSHAIRLABEL" "CROSSHAIRLABELRADIO" "CROSSHAIRLABELUCS" "CROSSHAIRZ" "CROSSINGAREACOLOR" "CheckDrawingSignature" "CmdHistLines" "CmdInputHistoryMax" "CmdLine.BackColor" "CmdLine.CmdOptBkColor" "CmdLine.CmdOptHighlightedColor" "CmdLine.CmdOptKeywordColor" "CmdLine.FontFace" "CmdLine.FontHeight" "CmdLine.FontItalic" "CmdLine.FontPitchAndFamily" "CmdLine.FontWeight" "CmdLine.ForeColor" "CmdLine.TempPromptBkColor" "CmdLine.TempPromptTextColor" "CmdVisLines" "ColorBookLocation" "CommandDialogs" "ConstraintBarMode" "ConstraintNameFormat" "ConstraintSolveMode" "ContextMenus" "ContinuousPlotLog" "Control vertices hull color" "Coords" "Copymode" "CreateViewports" "CursorSize" "CustomColors" "CustomDictionary" "DBLCLKEDIT" "DGNIMPORTMAX" "DGNMAPPINGPATH" "DGNOSNAP" "DIVMESHBOXHEIGHT" "DIVMESHBOXLENGTH" "DIVMESHBOXWIDTH" "DIVMESHCONEAXIS" "DIVMESHCONEBASE" "DIVMESHCONEHEIGHT" "DIVMESHCYLAXIS" "DIVMESHCYLBASE" "DIVMESHCYLHEIGHT" "DIVMESHPYRBASE" "DIVMESHPYRHEIGHT" "DIVMESHPYRLENGTH" "DIVMESHSPHEREAXIS" "DIVMESHSPHEREHEIGHT" "DIVMESHTORUSPATH" "DIVMESHTORUSSECTION" "DIVMESHWEDGEBASE" "DIVMESHWEDGEHEIGHT" "DIVMESHWEDGELENGTH" "DIVMESHWEDGESLOPE" "DIVMESHWEDGEWIDTH" "DTEXTED" "DWFOSNAP" "DYNCONSTRAINTMODE" "DYNDIGRIP" "DYNDIVIS" "DYNMODE" "DYNPICOORDS" "DYNPIFORMAT" "DYNPIVIS" "DYNPROMPT" "DYNTOOLTIPS" "DataLinkNotify" "DatabaseTablesOpenMode" "DatabaseWorkSpacePath" "DefaultConfig" "DefaultFormatForSave" "DefaultLayerZeroPlotStyle" "DefaultPlotStyle" "DefaultPlotToFile" "Delobj" "DigitizerArbitration" "DisableGraphicsTextArea" "DisableScreenMenuArea" "DisableTrueColor" "Dragmode" "EdgeMode" "EmergencyFont" "EnterpriseMenuFile" "EntityExtentVariant" "ExplorerInsertUnits" "FACETERMAXGRID" "FACETERMESHTYPE" "FACETERMINUGRID" "FACETERMINVGRID" "FACETERPRIMITIVEMODE" "FACETERSMOOTHLEV" "FULLPLOTPATH" "FieldDisplay" "FileDialog" "FontFace" "FontHeight" "FontItalic" "FontMappingFile" "FontPitchAndFamily" "FontWeight" "GEOLATLONGFORMAT" "GRIPSUBOBJMODE" "GTAUTO" "GTDEFAULT" "GTLOCATION" "GripBlock" "GripColor" "GripContour" "GripDynColor" "GripHot" "GripHover" "GripLegacy" "GripObjLimit" "GripObjSize" "GripSize" "GripTips" "Grips" "Group1" "HPMulti" "HPObjWarning" "HPOriginMode" "HPQUICKPREVTIMEOUT" "HatchGapTolerance" "HatchPatternAssociativity" "HatchType" "HideSystemPrinters" "HideWarningDialogs" "IESWEB" "INTELLIGENTUPDATE" "IconFilePath" "ImageHighlight" "Impliedface" "ImportPathInfo" "InputHistoryMode" "InsertUnitsDefSource" "InsertUnitsDefTarget" "IsaveBackupDwg" "IsavePercent" "LAYERDLGMODE" "LAYERFILTERALERT" "LEGACYCTRLPICK" "LWDEFAULT" "LargeObjectSupport" "LastModifiedConfig" "LastTemplate" "LayLockFadeCtl" "LayerEvalCtl" "Layout 3d AutoSnap Color" "Layout ATrack use tint" "Layout ATrack vector" "Layout AutoSnap Color" "Layout Dynamic Dimension Line color" "Layout Web color" "Layout Web shape color" "Layout Web(missing file) color" "Layout Xhair use tint" "Layout background" "Layout bk color" "Layout bk use tint" "Layout clipping color" "Layout color" "Layout contour color" "Layout end color" "Layout falloff color" "Layout frustrum color" "Layout glyphs color" "Layout grid axis lines color" "Layout grid axis lines tint" "Layout grid major lines color" "Layout grid major lines tint" "Layout grid minor lines color" "Layout grid minor lines tint" "Layout hotspot color" "Layout lux at distance color" "Layout start color" "LayoutRegenControl" "LayoutXhairPickboxEtc" "LineWeightDisplayScale" "LineWeightUnits" "LoadPaletteBySession" "LockUI" "LogFileOpen" "LogFilePath" "MENUBAR" "MRUFilesToAppMenu" "MRUFilesToList" "MTEXTCOLUMN" "MTEXTTOOLBAR" "MTextEditor" "MTextFixed" "MTextJigString" "MTextTSpaceType" "MainDictionary" "MaxApp" "MaxArray" "MaxDwg" "MaxHatch" "MaxOctTreeNodesToAllocate" "MaxQueuedEntsForPropChangeRegen" "MaxSortEntries" "Measureinit" "MenuFile" "MenuOptionFlags" "MiddleButtonPan" "ModeBits" "Model 3d AutoSnap Color" "Model ATrack use tint" "Model ATrack vector" "Model AutoSnap Color" "Model Dynamic Dimension Line Color" "Model Web color" "Model Web shape color" "Model Web(missing file) color" "Model Xhair use tint" "Model bk color" "Model bk use tint" "Model clipping color" "Model color" "Model contour color" "Model end color" "Model falloff color" "Model frustrum color" "Model glyphs color" "Model hotspot color" "Model lux at distance color" "Model start color" "MonoVectors" "MoreHideWarningDialogs" "NAVSWHEELMODE" "NAVSWHEELOPACITYBIG" "NAVSWHEELOPACITYMINI" "NAVSWHEELSIZEBIG" "NAVSWHEELSIZEMINI" "NAVVCUBELOCATION" "NAVVCUBEOPACITY" "NAVVCUBEORIENT" "NAVVCUBESIZE" "NFWState" "NetLocation" "OLEQUALITY" "OS" "ObjectSnapCursorSize" "OffsetCurveGapType" "OleHide" "OpenPartial" "Os" "OsOptions" "Osmode" "OsnapCoord" "OsnapHatch" "OsnapNodeLegacy" "PAPERUPDATE" "PATH" "PERSPECTIVECLIP" "PLOTLEGACY" "PLSPOOLALERT" "PREVIEWFILTER" "PSTYLEPOLICY" "PUBLISHALLSHEETS" "PUBLISHCOLLATE" "PUBLISHHATCH" "Parallel 3d AutoSnap Color" "Parallel ATrack use tint" "Parallel ATrack vector" "Parallel AutoSnap Color" "Parallel Dynamic Dimension Line Color" "Parallel Web color" "Parallel Web shape color" "Parallel Web(missing file) color" "Parallel Xhair color" "Parallel Xhair use tint" "Parallel background" "Parallel bk color" "Parallel bk use tint" "Parallel clipping color" "Parallel color" "Parallel contour color" "Parallel end color" "Parallel falloff color" "Parallel frustrum color" "Parallel glyphs color" "Parallel grid axis lines color" "Parallel grid axis lines tint" "Parallel grid major lines color" "Parallel grid major lines tint" "Parallel grid minor lines color" "Parallel grid minor lines tint" "Parallel hotspot color" "Parallel lux at distance color" "Parallel start color" "Parallel viewport control color" "ParameterSize" "Path" "PeditAccept" "Perspective 3d AutoSnap Color" "Perspective ATrack use tint" "Perspective ATrack vector" "Perspective AutoSnap Color" "Perspective Dynamic Dimension Line color" "Perspective Web color" "Perspective Web shape color" "Perspective Web(missing file) color" "Perspective Xhair color" "Perspective Xhair use tint" "Perspective bk color" "Perspective bk use tint" "Perspective clipping color" "Perspective color" "Perspective contour color" "Perspective end color" "Perspective falloff color" "Perspective frustrum color" "Perspective glyphs color" "Perspective grid axis lines color" "Perspective grid axis lines tint" "Perspective grid major lines color" "Perspective grid major lines tint" "Perspective grid minor lines color" "Perspective grid minor lines tint" "Perspective ground horizon" "Perspective ground origin" "Perspective hotspot color" "Perspective lux at distance color" "Perspective sky horizon" "Perspective sky zenith" "Perspective start color" "Perspective sub-surface azimuth" "Perspective sub-surface horizon" "Perspective viewport control color" "PickAdd" "PickAuto" "PickBox" "PickDrag" "PickFirst" "Pickstyle" "PlineConvertMode" "PlineType" "Plot preview background" "PlotLogPath" "PlotOffset" "PlotRotationMode" "PlotSpoolerDirectory" "PlotSpoolerNode" "PlotToFilePath" "PostscriptQuality" "PrinterConfigDir" "PrinterDescDir" "PrinterStyleSheetDir" "ProfileStorage" "QAFlags" "QPLOCATION" "QPMODE" "QVDRAWINGPIN" "QVDRAWINGPREVIEWSIZE" "QVLAYOUTPIN" "QVLAYOUTPREVIEWSIZE" "QVSMPREVIEWSIZE" "QnewTemplate" "R14RasterPlot" "RASTERDPI" "RASTERPERCENT" "RASTERTHRESHOLD" "RClickContextMenuTime" "REMEMBERFOLDERS" "RENDERUSERLIGHTS" "ROLLOVERTIPS" "RecoveryMode" "ReportError" "RtDisplay" "SDIMode" "SELECTIONANNODISPLAY" "SELECTIONAREAOPACITY" "SELECTLASTMODE" "SETBYLAYERMODE" "SHOWLAYERUSAGE" "SHOWMOTIONPIN" "SHOWZDYNAMIC" "SKIP2DREGENS" "SMOOTHMESHGRID" "SMOOTHMESHMAXFACE" "SMOOTHMESHMAXLEV" "SQLIndexInDwg" "SSMPOLLTIME" "SSMSHEETSTATUS" "STATUSBAR" "SaveFidelity" "SaveFilePath" "Scrollbars" "SelectionArea" "SelectionPreview" "SheetSetTemplatePath" "ShowFullPathInTitle" "ShowHyperlinkCursor" "ShowOleScaleDialog" "ShowPaperBackground" "ShowPaperMargins" "ShowPaperSize" "ShowPlotSetup" "ShowPrintBorder" "ShowProxyDialog" "ShowProxyGraphics" "ShowRuler" "ShowTabs" "SigWarn" "SnapType" "SsLocate" "SsmAutoOpen" "StandardsViolation" "StatusLine&CoordinateDisplay" "TABLETOOLBAR" "TBCUSTOMIZE" "THUMBSIZE" "TOOLTIPMERGE" "TableIndicator" "TempDirectory" "TemplatePath" "TextFill" "TextOutputFileFormat" "TextWindow.BackColor" "TextWindow.FontFace" "TextWindow.FontHeight" "TextWindow.FontItalic" "TextWindow.FontPitchAndFamily" "TextWindow.FontWeight" "TextWindow.ForeColor" "ThumbSave" "Trim&ExtendProjectMode" "Trimmode" "UCSAxisAng" "UCSDetect" "UCSOrtho" "UCSView" "USERPROFILE" "UcsIcon3d" "UcsIconActiveColor" "UcsIconApplySingleColor" "UcsIconCone" "UcsIconLineWidth" "UcsIconNonActiveColor" "UcsIconSize" "UndoLayerGrouping" "UndoZoomPanGrouping" "UseContextMenus" "UseMRUConfig" "UseMenuHeader" "UserName" "VPLAYEROVERRIDESMODE" "VPOverrideBackgroundColor" "VPROTATEASSOC" "Validation Policy" "Validation Strategy" "VtDuration" "VtEnable" "VtFps" "WINDOWAREACOLOR" "WhipArcEnable" "WhipThreadEnable" "XCROSSHAIRLABEL" "XDWGFADECTL" "XFadeCtl" "XhairPickboxEtc" "XrefControlFlags" "XrefLazyLoadMode" "XrefLoadPath" "XrefNotify" "XrefType" "YCROSSHAIRLABEL" "ZCROSSHAIRLABEL" "ZOOMWHEEL" "ZoomFactor" "_PKSER" "acedChangeCmdEchoWithoutUndo" "oS" "os" "tmp" "username")
 楼主| 发表于 2022-10-5 22:46:50 | 显示全部楼层
本帖最后由 tigcat 于 2022-10-5 23:07 编辑
guosheyang 发表于 2022-10-5 21:54
朋友  你处理完后 得到多少个变量  我按你的方法弄了   得到了500多个字符串 是不是这些值?
("2D Model ...

我得到的也是这些,不同cad版本得到的值是不同的。我的是cad2014,和cad2013应该差不多。其他的版本还是有点差别的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-15 22:49 , Processed in 0.186762 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表