用户输入文本内容,运行插件生成二维码(jpg图片格式),扫码即可显示文本内容。
※※※也可根据excel文件内容批量一键生成上万个二维码。※※※
效果如下:
首先需要引用库using ZXing;
部分代码如下:
public class 二维码
{
internal static List<string> tempFiles = new List<string>();
private static Point3d currentInsertPoint = new Point3d(0, 0, 0);
private const double qrCodeWidth = 300;
private const double spacing = qrCodeWidth / 5;
private static string folderPath;
[CommandMethod("xx")]
public void GenerateQR()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
db.EraseAll();
// 创建文件夹
string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
folderPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"文件夹_{timestamp}");
Directory.CreateDirectory(folderPath);
while (true)
{
if (!循环生成二维码(db, ed))
{
break;
}
}
}
}