mxcad 1.0.216 → 1.0.218
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mxcad.d.ts
CHANGED
|
@@ -2162,10 +2162,20 @@ export declare function getFilterImp(filter?: MxCADResbuf | null): any;
|
|
|
2162
2162
|
* MxCADResbuf 类用于操作 AutoCAD 中的 resbuf 数据。
|
|
2163
2163
|
* @example
|
|
2164
2164
|
* ```ts
|
|
2165
|
+
// 筛选图纸中的所有文字对象
|
|
2165
2166
|
import { MxCADResbuf } from "mxcad"
|
|
2166
|
-
|
|
2167
|
-
const filter = new MxCADResbuf()
|
|
2168
|
-
filter.AddMcDbEntityTypes("TEXT,MTEXT")
|
|
2167
|
+
// 定义过滤
|
|
2168
|
+
const filter = new MxCADResbuf();
|
|
2169
|
+
filter.AddMcDbEntityTypes("TEXT,MTEXT");
|
|
2170
|
+
// 设置选择,筛选文字对象
|
|
2171
|
+
let ss = new MxCADSelectionSet();
|
|
2172
|
+
ss.allSelect(filter);
|
|
2173
|
+
ss.forEach((id) => {
|
|
2174
|
+
let ent: any = id.getMcDbEntity();
|
|
2175
|
+
if (!ent) return;
|
|
2176
|
+
ent = McDbEntityToJsonObject(ent);
|
|
2177
|
+
console.log(JSON.stringify(ent));
|
|
2178
|
+
})
|
|
2169
2179
|
* ```
|
|
2170
2180
|
*/
|
|
2171
2181
|
export declare class MxCADResbuf extends McRxObject {
|
|
@@ -2175,8 +2185,8 @@ export declare class MxCADResbuf extends McRxObject {
|
|
|
2175
2185
|
* @example
|
|
2176
2186
|
* ```ts
|
|
2177
2187
|
* import { MxCADResbuf } from "mxcad"
|
|
2178
|
-
* //
|
|
2179
|
-
* const filter = new MxCADResbuf()
|
|
2188
|
+
* // 定义过滤器,过滤实体类型:直线,圆弧,圆,多义线
|
|
2189
|
+
* const filter = new MxCADResbuf([DxfCode.kEntityType, "LINE,ARC,CIRCLE,LWPOLYLINE"]));
|
|
2180
2190
|
* ```
|
|
2181
2191
|
*/
|
|
2182
2192
|
constructor(imp?: any);
|
|
@@ -2829,6 +2839,14 @@ export declare class MxCADSelectionSet extends McRxObject {
|
|
|
2829
2839
|
console.log(JSON.stringify(ent));
|
|
2830
2840
|
})
|
|
2831
2841
|
* ```
|
|
2842
|
+
* @example
|
|
2843
|
+
* ```ts
|
|
2844
|
+
import { MxCADSelectionSet } from "mxcad";
|
|
2845
|
+
let ss = new MxCADSelectionSet();
|
|
2846
|
+
// 得到图上,直线,圆,圆弧,多义线,在0层上的对象.
|
|
2847
|
+
ss.allSelect(new MxCADResbuf([DxfCode.kEntityType, "LINE,ARC,CIRCLE,LWPOLYLINE",DxfCode.kLayer,"0"]));
|
|
2848
|
+
console.log("得到对象数目:" + ss.count());
|
|
2849
|
+
* ```
|
|
2832
2850
|
* */
|
|
2833
2851
|
allSelect(filter?: MxCADResbuf | null): number;
|
|
2834
2852
|
/** 根据一个坐标点选择一个实体对象的索引
|
|
@@ -4253,7 +4271,7 @@ export declare class McDbEntity extends McDbObject {
|
|
|
4253
4271
|
* if (!id.isValid()) return;
|
|
4254
4272
|
* let ent:McDbEntity = id.getMcDbEntity();
|
|
4255
4273
|
* if (ent === null) return;
|
|
4256
|
-
* ent.setxData(new MxCADResbuf([{type:
|
|
4274
|
+
* ent.setxData(new MxCADResbuf([{type:DxfCode.kExDataName,val:"DataName"},{type:DxfCode.kString,val:"yyyyy"}]));
|
|
4257
4275
|
* ```
|
|
4258
4276
|
*/
|
|
4259
4277
|
setxData(xdata: MxCADResbuf): boolean;
|
|
@@ -4518,8 +4536,9 @@ export declare class McDbEntity extends McDbObject {
|
|
|
4518
4536
|
* 表示数据库曲线。实现了曲线的相关操作,如求曲线的长度,最近点,面积,曲线上任一点在曲线上的长度 切向方向,曲线交点,坐标变换,打断,偏移,离散等功能。
|
|
4519
4537
|
* @example
|
|
4520
4538
|
* ```ts
|
|
4521
|
-
|
|
4522
|
-
|
|
4539
|
+
* // 下面代码演示了,选择一个曲线,然后选择其它曲线,计算曲线与这个曲线的交点,然后在交点处打断曲线。
|
|
4540
|
+
import { MxCADUiPrEntity, MxCADResbuf, MxCpp, MxCADUtility, McDbCurve
|
|
4541
|
+
|
|
4523
4542
|
async function Mx_IntersectBreak() {
|
|
4524
4543
|
// 选择参考曲线
|
|
4525
4544
|
let eventObj = new MxCADUiPrEntity();
|
|
@@ -4528,14 +4547,16 @@ export declare class McDbEntity extends McDbObject {
|
|
|
4528
4547
|
let event = await eventObj_id.getMcDbEntity()//获取实例对象
|
|
4529
4548
|
if (event === null) return;
|
|
4530
4549
|
const mxcad = MxCpp.App.getCurrentMxCAD();
|
|
4531
|
-
let curve = event.clone()
|
|
4550
|
+
let curve = event.clone();// 克隆曲线
|
|
4532
4551
|
let filter = new MxCADResbuf();
|
|
4552
|
+
//设置过滤器 选中圆类、圆弧类、直线类、多段线类、椭圆类
|
|
4533
4553
|
filter.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE,ELLIPSE");
|
|
4534
4554
|
let aryId = await MxCADUtility.userSelect("选择打断对象", filter);//选中对象的id
|
|
4535
4555
|
if (aryId.length == 0) return
|
|
4556
|
+
// 遍历选中的曲线对象
|
|
4536
4557
|
aryId.forEach(async (id) => {
|
|
4537
4558
|
if (id.id !== eventObj_id.id) {
|
|
4538
|
-
let breakEvent: McDbCurve = (await id.getMcDbEntity()) as McDbCurve
|
|
4559
|
+
let breakEvent: McDbCurve = (await id.getMcDbEntity()) as McDbCurve;// 获取打断曲线的实例
|
|
4539
4560
|
let breakArr = breakEvent.IntersectWith(curve as McDbEntity, McDb.Intersect.kOnBothOperands);//与实体相交的点集合
|
|
4540
4561
|
if (breakArr.length() != 0) {
|
|
4541
4562
|
//有交点的对象
|
|
@@ -4557,15 +4578,16 @@ export declare class McDbEntity extends McDbObject {
|
|
|
4557
4578
|
breakPoint.push(pt1);
|
|
4558
4579
|
breakPoint.push(pt2);
|
|
4559
4580
|
});
|
|
4560
|
-
let breakcurve = breakEvent.splitCurves(breakPoint)
|
|
4581
|
+
let breakcurve = breakEvent.splitCurves(breakPoint);// 根据端点截取曲线
|
|
4561
4582
|
if (breakcurve.empty()) {
|
|
4562
4583
|
breakEvent.highlight(false);
|
|
4563
4584
|
return;
|
|
4564
4585
|
}
|
|
4586
|
+
// 重绘打断后的曲线
|
|
4565
4587
|
breakcurve.forEach((obj: McDbObject, index: number) => {
|
|
4566
4588
|
if (index % 2 == 0) mxcad.drawEntity(obj as McDbEntity);
|
|
4567
4589
|
});
|
|
4568
|
-
breakEvent.erase()
|
|
4590
|
+
breakEvent.erase() // 删除原曲线
|
|
4569
4591
|
}
|
|
4570
4592
|
}
|
|
4571
4593
|
})
|
|
@@ -4931,23 +4953,26 @@ export declare class McDbCurve extends McDbEntity {
|
|
|
4931
4953
|
* 表示一个直线对象。
|
|
4932
4954
|
* @example
|
|
4933
4955
|
* ```ts
|
|
4934
|
-
*
|
|
4956
|
+
* //参数绘直线 pt1,pt2是直线的两个点。
|
|
4935
4957
|
* import { MxCpp, McDbLine } from "mxcad"'
|
|
4936
4958
|
*
|
|
4937
|
-
* const line = new McDbLine();
|
|
4938
|
-
* line.startPoint = pt1;
|
|
4939
|
-
* line.endPoint = pt2;
|
|
4940
|
-
* MxCpp.getCurrentMxCAD().drawEntity(line);
|
|
4959
|
+
* const line = new McDbLine(); // 构造直线对象
|
|
4960
|
+
* line.startPoint = pt1; // 设置直线起点
|
|
4961
|
+
* line.endPoint = pt2; // 设置直线终点
|
|
4962
|
+
* MxCpp.getCurrentMxCAD().drawEntity(line); // 绘制直线
|
|
4941
4963
|
* ```
|
|
4942
4964
|
* ```ts
|
|
4965
|
+
//交互绘线,点击画布选择直线的起始点。
|
|
4943
4966
|
import { MxCADUiPrPoint, MxCpp } from "mxcad";
|
|
4944
|
-
|
|
4967
|
+
|
|
4945
4968
|
async function MxTest_DrawLine() {
|
|
4969
|
+
// 取起始点
|
|
4946
4970
|
const getPoint = new MxCADUiPrPoint();
|
|
4947
4971
|
getPoint.setMessage("\n指定第一点:");
|
|
4948
4972
|
let prvPoint = await getPoint.go();
|
|
4949
4973
|
if (!prvPoint) return;
|
|
4950
4974
|
getPoint.setMessage("\n指定下一个点:");
|
|
4975
|
+
// 循环取点
|
|
4951
4976
|
while (true) {
|
|
4952
4977
|
getPoint.setBasePt(prvPoint as any);
|
|
4953
4978
|
let pt = await getPoint.go();
|
|
@@ -5621,20 +5646,22 @@ export declare class McDbMText extends McDbEntity {
|
|
|
5621
5646
|
async function drawCircle() {
|
|
5622
5647
|
const getPoint = new MxCADUiPrPoint();
|
|
5623
5648
|
let circle = new McDbCircle();
|
|
5649
|
+
// 获取当前绘线颜色
|
|
5624
5650
|
let drawColor = MxCpp.getCurrentMxCAD().getCurrentDatabaseDrawColor();
|
|
5625
|
-
circle.trueColor = new McCmColor(drawColor)
|
|
5626
|
-
let drawMethod: "default" | "3P" | "2P" |
|
|
5651
|
+
circle.trueColor = new McCmColor(drawColor) //设置圆颜色
|
|
5652
|
+
let drawMethod: "default" | "3P" | "2P" | undefined
|
|
5627
5653
|
let isRadius: boolean | undefined
|
|
5628
5654
|
let center: McGePoint3d | null | undefined
|
|
5629
5655
|
let radius: number | undefined
|
|
5630
|
-
let point1: McGePoint3d | null |
|
|
5656
|
+
let point1: McGePoint3d | null | undefine
|
|
5631
5657
|
let point2: McGePoint3d | null | undefined
|
|
5632
5658
|
let point3: McGePoint3d | null | undefined
|
|
5633
5659
|
let endPoint1: McGePoint3d | null | undefined
|
|
5634
5660
|
let endPoint2: McGePoint3d | null | undefined
|
|
5661
|
+
|
|
5635
5662
|
while (true) {
|
|
5636
5663
|
if(typeof drawMethod === "undefined") {
|
|
5637
|
-
getPoint.setKeyWords("[三点(3P)/两点(2P)]")
|
|
5664
|
+
getPoint.setKeyWords("[三点(3P)/两点(2P)]");// 设置关键词
|
|
5638
5665
|
drawMethod = "default"
|
|
5639
5666
|
}
|
|
5640
5667
|
if (drawMethod === "default") {
|
|
@@ -5649,10 +5676,6 @@ export declare class McDbMText extends McDbEntity {
|
|
|
5649
5676
|
drawMethod = "2P"
|
|
5650
5677
|
continue
|
|
5651
5678
|
}
|
|
5652
|
-
// if(getPoint.isKeyWordPicked("T")) {
|
|
5653
|
-
// drawMethod = "T"
|
|
5654
|
-
// continue
|
|
5655
|
-
// }
|
|
5656
5679
|
if (!point) return
|
|
5657
5680
|
center = point
|
|
5658
5681
|
}
|
|
@@ -5764,9 +5787,6 @@ export declare class McDbMText extends McDbEntity {
|
|
|
5764
5787
|
radius = center.distanceTo(endPoint1)
|
|
5765
5788
|
return MxCpp.getCurrentMxCAD().drawEntity(new McDbCircle(center.x, center.y, center.z, radius))
|
|
5766
5789
|
}
|
|
5767
|
-
if(drawMethod === "T") {
|
|
5768
|
-
|
|
5769
|
-
}
|
|
5770
5790
|
}
|
|
5771
5791
|
}
|
|
5772
5792
|
* ```
|
|
@@ -6699,39 +6719,40 @@ export declare class McDbRotatedDimension extends McDbDimension {
|
|
|
6699
6719
|
* @example
|
|
6700
6720
|
* ```ts
|
|
6701
6721
|
import { MxCpp, MxDb2LineAngularDimension, MxCADUiPrPoint } from "mxcad";
|
|
6702
|
-
//
|
|
6722
|
+
// 下面代码演示了,先选择需要测量角度的两条边,再设置角度标注位置,最后绘制出角度标注对象。
|
|
6703
6723
|
function BR_AngleMeasure() {
|
|
6704
|
-
const angleDim = new McDb2LineAngularDimension()
|
|
6705
|
-
|
|
6724
|
+
const angleDim = new McDb2LineAngularDimension();// 构造新角度标注尺寸对象
|
|
6725
|
+
// 设置角边1起点
|
|
6706
6726
|
const getPoint1 = new MxCADUiPrPoint()
|
|
6707
6727
|
getPoint1.setMessage("\n指定线1起点:");
|
|
6708
6728
|
const point1 = await getPoint1.go();
|
|
6709
6729
|
if(!point1) return;
|
|
6710
6730
|
angleDim.xLine1Start = point1;
|
|
6711
|
-
|
|
6731
|
+
// 设置角边1终点
|
|
6712
6732
|
const getPoint2 = new MxCADUiPrPoint()
|
|
6713
6733
|
getPoint1.setMessage("\n指定线1终点:");
|
|
6714
6734
|
const point2 = await getPoint2.go();
|
|
6715
6735
|
if(!point2) return;
|
|
6716
6736
|
angleDim.xLine1End = point2;
|
|
6717
|
-
|
|
6737
|
+
// 设置角边2起点
|
|
6718
6738
|
const getPoint3 = new MxCADUiPrPoint()
|
|
6719
6739
|
getPoint3.setMessage("\n指定线2起点:");
|
|
6720
6740
|
const point3 = await getPoint3.go();
|
|
6721
6741
|
if(!point3) return;
|
|
6722
6742
|
angleDim.xLine2Start = point3;
|
|
6723
|
-
|
|
6743
|
+
// 设置角边2终点
|
|
6724
6744
|
const getPoint4 = new MxCADUiPrPoint();
|
|
6725
6745
|
getPoint4.setMessage("\n指定线2终点:");
|
|
6726
6746
|
const point4 = await getPoint4.go();
|
|
6727
6747
|
if(!point4) return;
|
|
6728
6748
|
angleDim.xLine2End = point4;
|
|
6729
|
-
|
|
6749
|
+
// 设置角度标注位置
|
|
6730
6750
|
const getArcPoint = new MxCADUiPrPoint()
|
|
6731
6751
|
getPoint3.setMessage("\n指定标注点:");
|
|
6732
6752
|
const arcPoint = await getArcPoint.go();
|
|
6733
6753
|
if(!arcPoint) return;
|
|
6734
6754
|
angleDim.arcPoint = arcPoint;
|
|
6755
|
+
// 绘制角度标注尺寸对象
|
|
6735
6756
|
MxCpp.getCurrentMxCAD().drawEntity(angleDim);
|
|
6736
6757
|
}
|
|
6737
6758
|
* ```
|
|
@@ -6755,13 +6776,13 @@ export declare class McDb2LineAngularDimension extends McDbDimension {
|
|
|
6755
6776
|
* ```ts
|
|
6756
6777
|
import { McDb2LineAngularDimension } from "mxcad";
|
|
6757
6778
|
|
|
6758
|
-
const angleDim = new McDb2LineAngularDimension()
|
|
6759
|
-
const getArcPoint = new MxCADUiPrPoint()
|
|
6779
|
+
const angleDim = new McDb2LineAngularDimension();
|
|
6780
|
+
const getArcPoint = new MxCADUiPrPoint();
|
|
6760
6781
|
getArcPoint.setMessage("\n指定标注点:");
|
|
6761
6782
|
const arcPoint = await getArcPoint.go();
|
|
6762
6783
|
if(!arcPoint) return;
|
|
6763
6784
|
angleDim.arcPoint = arcPoint;
|
|
6764
|
-
console.log(angleDim.arcPoint)
|
|
6785
|
+
console.log("输出文本标注点" , angleDim.arcPoint)
|
|
6765
6786
|
* ```
|
|
6766
6787
|
*/
|
|
6767
6788
|
get arcPoint(): McGePoint3d;
|
|
@@ -6888,15 +6909,15 @@ export declare class McDb2LineAngularDimension extends McDbDimension {
|
|
|
6888
6909
|
* 表示一个圆弧。
|
|
6889
6910
|
* @example
|
|
6890
6911
|
* ```ts
|
|
6891
|
-
|
|
6912
|
+
import { McDbArc, MxCpp } from "mxcad"
|
|
6892
6913
|
// 绘制圆弧
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6914
|
+
const arc = new McDbArc() // 构造新圆弧对象
|
|
6915
|
+
arc.center = new McGePoint3d(0,0,0) // 设置圆弧圆心
|
|
6916
|
+
arc.radius = 20 // 设置圆弧半径
|
|
6917
|
+
arc.startAngle = Math.PI / 2 // 设置圆弧开始角度
|
|
6918
|
+
arc.endAngle = Math.PI * 3 / 2 // 设置圆弧结束角度
|
|
6919
|
+
arc.trueColor = new McCmColor(255, 233, 0) // 设置圆弧颜色
|
|
6920
|
+
MxCpp.getCurrentMxCAD().drawEntity(arc) // 绘制圆弧
|
|
6900
6921
|
* ```
|
|
6901
6922
|
*/
|
|
6902
6923
|
export declare class McDbArc extends McDbCurve {
|
|
@@ -7303,8 +7324,8 @@ export declare class McDbPoint extends McDbEntity {
|
|
|
7303
7324
|
* 表示图案填充类,实现实心颜色填充和各种图案填充效果
|
|
7304
7325
|
* @example
|
|
7305
7326
|
* ```ts
|
|
7306
|
-
|
|
7307
|
-
|
|
7327
|
+
import { MxCADUiPrPoint, MxCADUtility, McDbHatch, MxCpp, McDb} from "mxcad"
|
|
7328
|
+
//选点填充
|
|
7308
7329
|
const getPoint = new MxCADUiPrPoint();
|
|
7309
7330
|
console.log("\n指定填充区域内部一点:");
|
|
7310
7331
|
let pt = (await getPoint.go()) as McGePoint3d;
|
|
@@ -9623,7 +9644,7 @@ export declare class McDbDatabase extends McRxObject {
|
|
|
9623
9644
|
* 数据库的块表记录对象,实现了对图块的属性相关操作函数。
|
|
9624
9645
|
* @example
|
|
9625
9646
|
* ```ts
|
|
9626
|
-
|
|
9647
|
+
// 添加图块
|
|
9627
9648
|
import { MxCpp, McDbBlockTableRecord, McDbBlockReference, McDbLine, McCmColor } from "mxcad"
|
|
9628
9649
|
|
|
9629
9650
|
let mxcad = MxCpp.getCurrentMxCAD();
|
|
@@ -9651,7 +9672,47 @@ export declare class McDbDatabase extends McRxObject {
|
|
|
9651
9672
|
|
|
9652
9673
|
mxcad.drawEntity(blkRef);
|
|
9653
9674
|
* ```
|
|
9654
|
-
|
|
9675
|
+
* ```ts
|
|
9676
|
+
// 改块颜色
|
|
9677
|
+
import { McDbBlockTableRecord, MxCADResbuf, MxCpp, McCmColor} from "mxcad";
|
|
9678
|
+
|
|
9679
|
+
async function Mx_BlkColor() {
|
|
9680
|
+
// 选择目标块
|
|
9681
|
+
let filter = new MxCADResbuf();
|
|
9682
|
+
filter.AddMcDbEntityTypes("INSERT");// 设置过滤器
|
|
9683
|
+
const getBlockEvent = new MxCADUiPrEntity()
|
|
9684
|
+
getBlockEvent.setMessage('选择需要修改基点的块');
|
|
9685
|
+
getBlockEvent.setFilter(filter);
|
|
9686
|
+
const block_id = await getBlockEvent.go();
|
|
9687
|
+
if (!block_id.id) return;
|
|
9688
|
+
// 块实体
|
|
9689
|
+
const blkRef = block_id.getMcDbEntity() as McDbBlockReference;
|
|
9690
|
+
let blkRec = blkRef.blockTableRecordId.getMcDbBlockTableRecord();
|
|
9691
|
+
Mx_ModyfBlockRecordEntityColor(blkRec);// 设置块颜色类型
|
|
9692
|
+
|
|
9693
|
+
// 设置块颜色
|
|
9694
|
+
const getColor = new MxCADUiPrInt();
|
|
9695
|
+
getColor.setMessage('输入颜色索引(0~256)');
|
|
9696
|
+
let colorNum = await getColor.go() || 0;
|
|
9697
|
+
let color = new McCmColor();
|
|
9698
|
+
color.setColorIndex(colorNum);
|
|
9699
|
+
blkRef.trueColor = color;
|
|
9700
|
+
const mxcad = MxCpp.getCurrentMxCAD();
|
|
9701
|
+
mxcad.updateDisplay()
|
|
9702
|
+
}
|
|
9703
|
+
// 设置块颜色类型
|
|
9704
|
+
function Mx_ModyfBlockRecordEntityColor(blkRec: McDbBlockTableRecord) {
|
|
9705
|
+
blkRec.getAllEntityId().forEach(id => {
|
|
9706
|
+
let ent = id.getMcDbEntity();
|
|
9707
|
+
ent.colorIndex = ColorIndexType.kByblock;
|
|
9708
|
+
if (ent instanceof McDbBlockReference) {
|
|
9709
|
+
let blkref = ent as McDbBlockReference;
|
|
9710
|
+
Mx_ModyfBlockRecordEntityColor(blkref.blockTableRecordId.getMcDbBlockTableRecord());
|
|
9711
|
+
}
|
|
9712
|
+
})
|
|
9713
|
+
}
|
|
9714
|
+
* ```
|
|
9715
|
+
*/
|
|
9655
9716
|
export declare class McDbBlockTableRecord extends McDbObject {
|
|
9656
9717
|
/**
|
|
9657
9718
|
* 构造函数。
|
|
@@ -9768,12 +9829,16 @@ export declare class McDbBlockTableRecord extends McDbObject {
|
|
|
9768
9829
|
* 数据库中的块表类,块表中存放着块表记录。
|
|
9769
9830
|
* @example
|
|
9770
9831
|
* ```ts
|
|
9771
|
-
*
|
|
9832
|
+
* //遍历图纸中的所有图块
|
|
9772
9833
|
* import { MxCpp, McDbBlockTable } from "mxcad"
|
|
9773
9834
|
*
|
|
9835
|
+
* // 获取当前cad对象
|
|
9774
9836
|
* let mxcad = MxCpp.App.getCurrentMxCAD();
|
|
9837
|
+
* // 获取块表对象
|
|
9775
9838
|
* let blockTable: McDbBlockTable = mxcad.getDatabase().getBlockTable();
|
|
9839
|
+
* // 获取块表中的所有记录对象id
|
|
9776
9840
|
* let aryId = blockTable.getAllRecordId();
|
|
9841
|
+
* //遍历记录对象id,获取块表记录对象详情
|
|
9777
9842
|
* aryId.forEach((id) => {
|
|
9778
9843
|
* let blkRec = id.getMcDbBlockTableRecord();
|
|
9779
9844
|
* if (blkRec === null) return;
|
|
@@ -10326,7 +10391,7 @@ export declare class McObject {
|
|
|
10326
10391
|
* import { MxCpp, McObject } from "mxcad"
|
|
10327
10392
|
*
|
|
10328
10393
|
* const mxcad:McObject = MxCpp.getCurrentMxCAD();
|
|
10329
|
-
* .on("selectChange", (ids)=> {
|
|
10394
|
+
* mxcad.on("selectChange", (ids)=> {
|
|
10330
10395
|
* let ent = id.getMcDbEntity()
|
|
10331
10396
|
* if(!ent) return
|
|
10332
10397
|
* console.log(ent.objectName)
|
|
@@ -10928,10 +10993,8 @@ export declare class McObject {
|
|
|
10928
10993
|
*/
|
|
10929
10994
|
set drawLineWidth(val: number);
|
|
10930
10995
|
/**
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
* ```
|
|
10934
|
-
*/
|
|
10996
|
+
* 返回调用draw开头的绘图数,使用数据库的当前默认属性。
|
|
10997
|
+
*/
|
|
10935
10998
|
get drawUseDefaultProperties(): boolean;
|
|
10936
10999
|
/**
|
|
10937
11000
|
* 设置调用draw开头的绘图数,使用数据库的当前默认属性
|
|
@@ -11094,6 +11157,12 @@ export declare class McObject {
|
|
|
11094
11157
|
* 绘制点
|
|
11095
11158
|
* @param dX X 坐标
|
|
11096
11159
|
* @param dY Y 坐标
|
|
11160
|
+
* @example
|
|
11161
|
+
* ```ts
|
|
11162
|
+
* import { MxCpp, McObject } from "mxcad"
|
|
11163
|
+
* const mxcad:McObject = MxCpp.getCurrentMxCAD()
|
|
11164
|
+
* mxcad.drawPoint(0,0);
|
|
11165
|
+
* ```
|
|
11097
11166
|
*/
|
|
11098
11167
|
drawPoint(dX: number, dY: number): McObjectId;
|
|
11099
11168
|
/**
|
|
@@ -11265,7 +11334,7 @@ export declare class McObject {
|
|
|
11265
11334
|
* ```ts
|
|
11266
11335
|
* import { MxCpp, McObject } from "mxcad"
|
|
11267
11336
|
* const mxcad:McObject = MxCpp.getCurrentMxCAD()
|
|
11268
|
-
|
|
11337
|
+
* mxcad.pathMoveTo(0, 300);
|
|
11269
11338
|
* ```
|
|
11270
11339
|
*/
|
|
11271
11340
|
pathMoveTo(dX: number, dY: number): void;
|
|
@@ -11279,7 +11348,7 @@ export declare class McObject {
|
|
|
11279
11348
|
* ```ts
|
|
11280
11349
|
* import { MxCpp, McObject } from "mxcad"
|
|
11281
11350
|
* const mxcad:McObject = MxCpp.getCurrentMxCAD()
|
|
11282
|
-
|
|
11351
|
+
* mxcad.pathMoveToEx(1000, 300, 10, 10, 0);
|
|
11283
11352
|
* ```
|
|
11284
11353
|
*/
|
|
11285
11354
|
pathMoveToEx(dX: number, dY: number, dStartWidth: number, dEndWidth: number, dBulge: number): void;
|
|
@@ -11291,7 +11360,7 @@ export declare class McObject {
|
|
|
11291
11360
|
* ```ts
|
|
11292
11361
|
* import { MxCpp, McObject } from "mxcad"
|
|
11293
11362
|
* const mxcad:McObject = MxCpp.getCurrentMxCAD()
|
|
11294
|
-
|
|
11363
|
+
* mxcad.pathLineTo(100, 300);
|
|
11295
11364
|
* ```
|
|
11296
11365
|
*/
|
|
11297
11366
|
pathLineTo(dX: number, dY: number): void;
|
|
@@ -11306,7 +11375,7 @@ export declare class McObject {
|
|
|
11306
11375
|
* ```ts
|
|
11307
11376
|
* import { MxCpp, McObject } from "mxcad"
|
|
11308
11377
|
* const mxcad:McObject = MxCpp.getCurrentMxCAD()
|
|
11309
|
-
|
|
11378
|
+
* mxcad.pathLineToEx(1000, 500, 30, 0, 0);
|
|
11310
11379
|
* ```
|
|
11311
11380
|
*/
|
|
11312
11381
|
pathLineToEx(dX: number, dY: number, dStartWidth: number, dEndWidth: number, dBulge: number): void;
|
|
@@ -11314,8 +11383,8 @@ export declare class McObject {
|
|
|
11314
11383
|
* 根据圆对象创建一个路径
|
|
11315
11384
|
* @example
|
|
11316
11385
|
* ```ts
|
|
11317
|
-
|
|
11318
|
-
|
|
11386
|
+
import { MxCpp, McObject } from "mxcad"
|
|
11387
|
+
const mxcad:McObject = MxCpp.getCurrentMxCAD()
|
|
11319
11388
|
mxcad.pathCircle(0, 0, 20);
|
|
11320
11389
|
* ```
|
|
11321
11390
|
*/
|
|
@@ -11338,6 +11407,33 @@ export declare class McObject {
|
|
|
11338
11407
|
* 将路径转换为填充图案
|
|
11339
11408
|
* @param dPatternScale - 图案缩放比例
|
|
11340
11409
|
* @returns 转换结果
|
|
11410
|
+
* @example
|
|
11411
|
+
* ```ts
|
|
11412
|
+
import { MxCADUiPrPoint, MxCADUiPrDist, MxCpp } from "mxcad";
|
|
11413
|
+
// 实心圆
|
|
11414
|
+
async function Mx_SolidCircle() {
|
|
11415
|
+
const getCenter = new MxCADUiPrPoint();
|
|
11416
|
+
getCenter.setMessage('请确定圆心位置\n');
|
|
11417
|
+
const center = await getCenter.go();
|
|
11418
|
+
if (!center) return;
|
|
11419
|
+
const getRadius = new MxCADUiPrDist();
|
|
11420
|
+
getRadius.setBasePt(center);// 设置距离基点为圆心
|
|
11421
|
+
getRadius.setMessage('请输入圆半径');
|
|
11422
|
+
getRadius.setUserDraw((pt, pw) => {
|
|
11423
|
+
const r = pt.distanceTo(center);
|
|
11424
|
+
const circle = new McDbCircle();
|
|
11425
|
+
circle.center = center;
|
|
11426
|
+
circle.radius = r;
|
|
11427
|
+
pw.drawMcDbEntity(circle)
|
|
11428
|
+
})
|
|
11429
|
+
const radiusVal = await getRadius.go();
|
|
11430
|
+
if (!radiusVal) return;
|
|
11431
|
+
const radius = getRadius.value();
|
|
11432
|
+
const mxcad = MxCpp.getCurrentMxCAD();
|
|
11433
|
+
mxcad.pathCircle(center.x, center.y, radius);//设置圆路径
|
|
11434
|
+
mxcad.drawPathToHatch();// 绘制实心圆
|
|
11435
|
+
}
|
|
11436
|
+
* ```
|
|
11341
11437
|
*/
|
|
11342
11438
|
drawPathToHatch(dPatternScale?: number): McObjectId;
|
|
11343
11439
|
/**
|
|
@@ -12551,6 +12647,24 @@ export declare function MxCheckTheBrowser(): {
|
|
|
12551
12647
|
};
|
|
12552
12648
|
/**
|
|
12553
12649
|
* createMxCad 的参数配置
|
|
12650
|
+
* @example
|
|
12651
|
+
* ```ts
|
|
12652
|
+
createMxCad({
|
|
12653
|
+
canvas: "#mxcad",
|
|
12654
|
+
locateFile: (fileName) => new URL(`/node_modules/mxcad/dist/wasm/2d/${fileName}`, import.meta.url).href,
|
|
12655
|
+
// 提供要打开的文件 注意../assets/test.mxweb 是相对路径下的文件地址,
|
|
12656
|
+
// 在vite中可用通过这样的方式得到该文件正确的的网络地址
|
|
12657
|
+
fileUrl: new URL("../assets/test.mxweb", import.meta.url).href,
|
|
12658
|
+
// 提供加载字体的目录路径
|
|
12659
|
+
fontspath: new URL("node_modules/mxcad/dist/fonts", import.meta.url).href,
|
|
12660
|
+
viewBackgroundColor:{red:0,green:0,blue:0}, //黑色背景
|
|
12661
|
+
middlePan:false, //禁用鼠标中间键操作
|
|
12662
|
+
multipleSelect: true, // 开启多选
|
|
12663
|
+
onOpenFileComplete:()=>{
|
|
12664
|
+
console.log("成功打开文件!")
|
|
12665
|
+
}
|
|
12666
|
+
})
|
|
12667
|
+
* ```
|
|
12554
12668
|
*/
|
|
12555
12669
|
export interface MxCadConfig {
|
|
12556
12670
|
/** 获取加载wasm相关文件(wasm/js/worker.js)路径位置
|
|
@@ -12559,11 +12673,6 @@ export interface MxCadConfig {
|
|
|
12559
12673
|
* @returns filePath 默认采用base + fileName
|
|
12560
12674
|
* @abstract 本质上locateFile配置函数就是返回wasm相关文件在自己的服务器上的位置
|
|
12561
12675
|
* 在npm包中`node_modules/mxcad/dist/wasm/2d/`下的文件就是支持2d的相关wasm文件
|
|
12562
|
-
* @example
|
|
12563
|
-
* ```js
|
|
12564
|
-
* // 在vite中只需要如下代码:
|
|
12565
|
-
* locateFile(fileName) { return new URL("/node_modules/mxcad/dist/wasm/2d/${fileName}", import.meta.url).href}
|
|
12566
|
-
* ```
|
|
12567
12676
|
*/
|
|
12568
12677
|
locateFile?: (fileName: string, base?: string | URL) => string;
|
|
12569
12678
|
/** WebAssembly 模块二进制文件 默认情况无需配置 **/
|
|
@@ -12598,22 +12707,6 @@ export interface MxCadConfig {
|
|
|
12598
12707
|
fileUrl?: string;
|
|
12599
12708
|
/**
|
|
12600
12709
|
* 监听打开文件成功回调事件
|
|
12601
|
-
* @example
|
|
12602
|
-
* ```ts
|
|
12603
|
-
* import { createMxCad } from "mxcad";
|
|
12604
|
-
* createMxCad({
|
|
12605
|
-
* canvas: "#mxcad",
|
|
12606
|
-
* locateFile: (fileName) => new URL(`/node_modules/mxcad/dist/wasm/2d/${fileName}`, import.meta.url).href,
|
|
12607
|
-
* // 提供要打开的文件 注意../assets/test.mxweb 是相对路径下的文件地址,
|
|
12608
|
-
* // 在vite中可用通过这样的方式得到该文件正确的的网络地址
|
|
12609
|
-
* fileUrl: new URL("../assets/test.mxweb", import.meta.url).href,
|
|
12610
|
-
* // 提供加载字体的目录路径
|
|
12611
|
-
* fontspath: new URL("node_modules/mxcad/dist/fonts", import.meta.url).href,
|
|
12612
|
-
* onOpenFileComplete:()=>{
|
|
12613
|
-
* console.log("成功打开文件!")
|
|
12614
|
-
* }
|
|
12615
|
-
* })
|
|
12616
|
-
* ```
|
|
12617
12710
|
*/
|
|
12618
12711
|
onOpenFileComplete?: Function;
|
|
12619
12712
|
/** 字体文件加载路径,默认是fonts */
|
|
@@ -12630,19 +12723,6 @@ export interface MxCadConfig {
|
|
|
12630
12723
|
registfile?: string;
|
|
12631
12724
|
/**
|
|
12632
12725
|
* 视区背景颜色
|
|
12633
|
-
* @example
|
|
12634
|
-
* ```ts
|
|
12635
|
-
createMxCad({
|
|
12636
|
-
canvas: "#mxcad",
|
|
12637
|
-
locateFile: (fileName) => new URL(`/node_modules/mxcad/dist/wasm/2d/${fileName}`, import.meta.url).href,
|
|
12638
|
-
// 提供要打开的文件 注意../assets/test.mxweb 是相对路径下的文件地址,
|
|
12639
|
-
// 在vite中可用通过这样的方式得到该文件正确的的网络地址
|
|
12640
|
-
fileUrl: new URL("../assets/test.mxweb", import.meta.url).href,
|
|
12641
|
-
// 提供加载字体的目录路径
|
|
12642
|
-
fontspath: new URL("node_modules/mxcad/dist/fonts", import.meta.url).href,
|
|
12643
|
-
viewBackgroundColor:{red:0,green:0,blue:0}//黑色背景
|
|
12644
|
-
})
|
|
12645
|
-
* ```
|
|
12646
12726
|
*/
|
|
12647
12727
|
viewBackgroundColor?: {
|
|
12648
12728
|
red: number;
|
package/dist/mxcad.es.js
CHANGED
|
@@ -14145,7 +14145,7 @@ win.McDrawObjectEvent_asciiToUTF8 = function (hexstr) {
|
|
|
14145
14145
|
return MxG2312Obj.decodeFromGb2312(hexstr);
|
|
14146
14146
|
};
|
|
14147
14147
|
|
|
14148
|
-
const version$1 = "1.0.
|
|
14148
|
+
const version$1 = "1.0.218";
|
|
14149
14149
|
|
|
14150
14150
|
var isSharedArrayBuffer = ("SharedArrayBuffer" in window);
|
|
14151
14151
|
var isCdn = document.currentScript && /unpkg\.com\/mxcad/.test(document.currentScript.src);
|
|
@@ -14746,7 +14746,7 @@ var MxCADResbuf = /*#__PURE__*/function (_McRxObject) {
|
|
|
14746
14746
|
}
|
|
14747
14747
|
}
|
|
14748
14748
|
if (aryObj.length > 0) {
|
|
14749
|
-
_this.setJson(JSON.stringify(
|
|
14749
|
+
_this.setJson(JSON.stringify(aryObj));
|
|
14750
14750
|
}
|
|
14751
14751
|
}
|
|
14752
14752
|
} else {
|