乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 117|回复: 8

Bricscad ET Chspace-like命令

[复制链接]

14

主题

67

帖子

8

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
122
发表于 2010-4-10 08:28:59 | 显示全部楼层 |阅读模式
我需要帮助 我正在尝试编写Acad Express Tools Chang Space命令,用于将实体从MS复制到PS,但运气不佳 本人'm使用VBA,因为它'幸运的是,它易于调试/运行 我找到了复制和旋转到viewtwist的方法,但我可以#039;我似乎没有像预期的那样工作 我需要将模型中的文本插入点转换为acadPViewport中的相同点 有谁在Bricscad做到了这一点 我之所以说Bricscad,是因为它似乎并没有像我预期的那样工作,也没有像Acad代码示例所显示的那样工作 求助于方向-目标 当它从Mspace切换到Pspace时,我一直遇到再生问题,这可能会造成严重破坏 如有任何建议,我们将不胜感激。
回复

使用道具 举报

0

主题

9

帖子

4

银币

初来乍到

Rank: 1

铜币
11
发表于 2010-4-10 12:27:30 | 显示全部楼层
使用现有的express工具会更容易 如果你在谷歌上搜索'chspace.lsp&#039 allexperts的版本。com来自Autodesk Australia,版权声明允许免费使用 请注意,这与美国版本的Autocad中的express tools中的版本不同 还有Randy Kintzley发布的版本副本,这是美国express tools中的版本。
回复

使用道具 举报

0

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
13
发表于 2010-4-10 16:48:13 | 显示全部楼层
我认为这将不得不做,基本上我可以复制与基地,并实现相同的。如果有人可以使用com、VBA或Vlax将MSpace坐标转换为PSace坐标,我仍然很感兴趣。
回复

使用道具 举报

0

主题

9

帖子

5

银币

初来乍到

Rank: 1

铜币
10
发表于 2010-4-10 23:47:36 | 显示全部楼层
嗨,Jerry,我的VBA咬伤了,也许你可以翻译一下。我在几个端口进行了测试,其中一些端口进行了旋转(dview),它似乎可以工作。YMMV,但我希望它能让你开始
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using System.Diagnostics;
  7. using BricscadApp;
  8. using BricscadDb;
  9. using RxNet.ApplicationServices;
  10. using RxNet.Runtime;
  11. using RxNet.Geometry;
  12. using RxNet.RxGlobal;
  13. namespace Bricscad
  14. {
  15.   public static class Commands
  16.   {
  17.     // from papaerspace vp is active
  18.     [CommandMethod("doit")]
  19.     public static void test01()
  20.     {
  21.       try
  22.       {
  23.         // get app stuff
  24.         var app = Application.AcadApplication as AcadApplication;
  25.         var doc = app.ActiveDocument;
  26.         var mspace = doc.ModelSpace;
  27.         GlobalFunctions.MSpace();
  28.         //select an entity and copy
  29.         object opnt, oent, pairs = null;
  30.         doc.Utility.GetEntity(out oent, out opnt, "Select Entity");
  31.         AcadEntity entity = oent as AcadEntity;
  32.         AcadEntity[] ocol = { entity };
  33.         object[] ncol = doc.CopyObjects((object)ocol, doc.PaperSpace, ref pairs);
  34.         AcadEntity nentity = ncol[0] as AcadEntity;
  35.         // get the center of both entities bounding box
  36.         Point3d cenent = getBBCenter(entity);
  37.         Point3d cennent = getBBCenter(nentity);
  38.         // scale
  39.         nentity.ScaleEntity(cennent.ToArray(), doc.ActivePViewport.CustomScale);
  40.         // rotate
  41.         nentity.Rotate(cennent.ToArray(), doc.ActivePViewport.TwistAngle);
  42.         // move
  43.         nentity.Move(cennent.ToArray(),
  44.           doc.Utility.TranslateCoordinates(
  45.           cenent.ToArray(), AcCoordinateSystem.acUCS, AcCoordinateSystem.acPaperSpaceDCS, 0));
  46.         // delete
  47.         entity.Delete();
  48.         GlobalFunctions.PSpace();
  49.       }
  50.       catch (System.Exception ex)
  51.       {
  52.         GlobalFunctions.Printf("\n{0}\n{1}",
  53.          ex.Message, ex.StackTrace);
  54.       }
  55.     }
  56.     static Point3d getBBCenter(AcadEntity ent)
  57.     {
  58.       object omin, omax;
  59.       ent.GetBoundingBox(out omin, out omax);
  60.       Point3d min = new Point3d((double[])omin);
  61.       Point3d max = new Point3d((double[])omax);
  62.       return new Point3d(min[0] + ((max[0] - min[0]) / 2),
  63.                          min[1] + ((max[1] - min[1]) / 2), 0);
  64.     }
  65.   }
  66. }

回复

使用道具 举报

0

主题

9

帖子

6

银币

初来乍到

Rank: 1

铜币
11
发表于 2010-4-10 23:50:26 | 显示全部楼层
突出显示的项目从MS克隆到PS,VP扭曲。。。
回复

使用道具 举报

0

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
6
发表于 2010-4-11 00:21:34 | 显示全部楼层
在选择集上工作时,您可能需要过滤DIM
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using System.Diagnostics;
  7. using BricscadApp;
  8. using BricscadDb;
  9. using RxNet.ApplicationServices;
  10. using RxNet.Runtime;
  11. using RxNet.Geometry;
  12. using RxNet.RxGlobal;
  13. namespace Bricscad
  14. {
  15.   public static class Commands
  16.   {
  17.     // from papaerspace vp is active
  18.     [CommandMethod("doit")]
  19.     public static void test01()
  20.     {
  21.       AcadSelectionSet selection = null;
  22.       try
  23.       {
  24.         // get app stuff
  25.         var app = Application.AcadApplication as AcadApplication;
  26.         var doc = app.ActiveDocument;
  27.         GlobalFunctions.MSpace();
  28.         selection = doc.SelectionSets.Add("MySel");
  29.         selection.SelectOnScreen();
  30.         foreach (AcadObject o in selection)
  31.         {
  32.           AcadEntity e = o as AcadEntity;
  33.           if (e != null)
  34.             cloneToPspace(e, doc);
  35.         }
  36.         foreach (AcadObject o in selection)
  37.         {
  38.           AcadEntity e = o as AcadEntity;
  39.           if (e != null)
  40.             e.Delete();
  41.         }
  42.         GlobalFunctions.PSpace();
  43.       }
  44.       catch (System.Exception ex)
  45.       {
  46.         GlobalFunctions.Printf("\n{0}\n{1}",
  47.          ex.Message, ex.StackTrace);
  48.       }
  49.       finally
  50.       {
  51.         selection.Delete();
  52.       }
  53.     }
  54.     static void cloneToPspace(AcadEntity entity, AcadDocument doc)
  55.     {
  56.       try
  57.       {
  58.         object pairs = null;
  59.         AcadEntity[] ocol = { entity };
  60.         object[] ncol = doc.CopyObjects((object)ocol, doc.PaperSpace, ref pairs);
  61.         AcadEntity nentity = ncol[0] as AcadEntity;
  62.         // get the center of both entities bounding box
  63.         Point3d cenent = getBBCenter(entity);
  64.         Point3d cennent = getBBCenter(nentity);
  65.         // scale
  66.         nentity.ScaleEntity(cennent.ToArray(), doc.ActivePViewport.CustomScale);
  67.         // rotate
  68.         nentity.Rotate(cennent.ToArray(), doc.ActivePViewport.TwistAngle);
  69.         // move
  70.         nentity.Move(cennent.ToArray(),
  71.           doc.Utility.TranslateCoordinates(
  72.           cenent.ToArray(), AcCoordinateSystem.acUCS, AcCoordinateSystem.acPaperSpaceDCS, 0));
  73.       }
  74.       catch {/*hehe*/}
  75.     }
  76.     static Point3d getBBCenter(AcadEntity ent)
  77.     {
  78.       object omin, omax;
  79.       ent.GetBoundingBox(out omin, out omax);
  80.       Point3d min = new Point3d((double[])omin);
  81.       Point3d max = new Point3d((double[])omax);
  82.       return new Point3d(min[0] + ((max[0] - min[0]) / 2),
  83.                          min[1] + ((max[1] - min[1]) / 2), 0);
  84.     }
  85.   }
  86. }
回复

使用道具 举报

0

主题

14

帖子

5

银币

初来乍到

Rank: 1

铜币
14
发表于 2010-4-11 05:46:16 | 显示全部楼层
小子,你下达了全面的命令 看起来不错。哈文#039;我没有试过你的代码,因为我正处于一个特定的使用过程中 我得到了一张包含所有注释(方位、距离、注释等)的测量地图,需要将其分为3张,具有两个不同的比例和重叠区域。一些文本需要保持水平,一些对齐,一些1:50,一些1:100
  1. Sub msTxt2ps()
  2.       Dim pp As Variant
  3.       Dim pt1 As Variant
  4.       Dim ent As AcadEntity
  5.       Dim aTxt As AcadText
  6.       Dim mTxt As AcadMText
  7.       Dim nTxt As AcadText
  8.       Dim amTxt As AcadMText
  9.       Dim mAtt As Variant
  10.       
  11.       Dim ss As AcadSelectionSet
  12.       Dim Code(0) As Integer
  13.       Dim Val(0) As Variant
  14.       Set ss = ThisDrawing.ActiveSelectionSet
  15.       ss.Clear
  16.           Code(0) = 0
  17.           Val(0) = "TEXT,MTEXT"
  18.          
  19.      Dim styl As AcadTextStyle
  20.      Set styl = ThisDrawing.ActiveTextStyle
  21.       
  22.       Dim ps As AcadPViewport
  23.       Set ps = ThisDrawing.ActivePViewport
  24.       pss = ps.CustomScale
  25.       psrot = ps.TwistAngle
  26.       
  27.       ss.SelectOnScreen Code, Val
  28.       ThisDrawing.ActiveSpace = acPaperSpace
  29. For Each ent In ss
  30.       If TypeOf ent Is AcadText Then
  31.           Set aTxt = ent
  32.           pt1 = aTxt.InsertionPoint
  33.           pt1 = transPt(pt1)
  34.           rot = Math.Round(aTxt.Rotation, 5)
  35.           pt2 = aTxt.TextAlignmentPoint
  36.           pt2 = transPt(pt2)
  37.           txtht = aTxt.Height * pss
  38.           Set nTxt = ThisDrawing.PaperSpace.AddText(aTxt.TextString, pt1, txtht)
  39.           nTxt.Alignment = aTxt.Alignment
  40.           nTxt.TextAlignmentPoint = pt2
  41.           nTxt.InsertionPoint = pt1
  42.                If rot = 0# Then
  43.                nTxt.Rotation = 0#
  44.                Else
  45.                nTxt.Rotation = rot + psrot
  46.                End If
  47.           Else
  48.           Set mTxt = ent
  49.           pt1 = mTxt.InsertionPoint
  50.           pt1 = transPt(pt1)
  51.           rot = Math.Round(mTxt.Rotation, 5)
  52.           wid = mTxt.Width
  53.           mAtt = mTxt.AttachmentPoint
  54.           Set amTxt = ThisDrawing.PaperSpace.AddMText(pt1, wid, mTxt.TextString)
  55.           amTxt.AttachmentPoint = mAtt
  56.                If rot = 0# Then
  57.                amTxt.Rotation = 0#
  58.                Else
  59.                amTxt.Rotation = rot + psrot
  60.                End If
  61.           amTxt.StyleName = styl.Name
  62.           amTxt.ScaleEntity pt1, pss
  63.      End If
  64. Next
  65.       
  66. End Sub
  67. Function transPt(ByRef pt1 As Variant) As Variant
  68.      pt1 = ThisDrawing.Utility.TranslateCoordinates(pt1, acUCS, acDisplayDCS, 0)
  69.      pt1 = ThisDrawing.Utility.TranslateCoordinates(pt1, acDisplayDCS, acPaperSpaceDCS, 0)
  70.      transPt = pt1
  71. End Function
有趣的是你没有't必须将自定义比例因子应用于Mtext.Width。或者在我看来是这样的;我会检查你的代码,这样也许我可以为将来开发一些Mspace2Pspace工具 非常感谢。
回复

使用道具 举报

0

主题

9

帖子

5

银币

初来乍到

Rank: 1

铜币
11
发表于 2010-4-11 07:23:57 | 显示全部楼层
干得好!我看到你了;重新创建新实体,而我正在使用CopyObjects功能…为什么我需要缩放对象
顺便说一句,我只使用C,因为我'我对它比较舒服。没有理由这样做;t被移植到VBA…它的所有组件;
回复

使用道具 举报

0

主题

7

帖子

5

银币

初来乍到

Rank: 1

铜币
8
发表于 2010-4-12 05:19:28 | 显示全部楼层
我之所以创建新对象,是因为我找到了最简单的方法将它们放在新层(当前层)上,而我没有&35;039;我不想删除原件,只需将其关闭,因为同一文本可能需要复制到不同的版面 我的下一个项目是出于同样的原因将纪念碑符号(块)转换成PS 将很简单,除非符号包含擦除实体 复制它们不会'我似乎没有遵守提款顺序 一旦他们进入纸面空间,将他们带到前台似乎取得了喜忧参半的成功。我一定忽略了什么 无论如何,必须尽快完成此映射,因此必须等待编写例程。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-1 19:35 , Processed in 0.380243 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表