single-yu 发表于 2010-4-24 12:58:00

[求助]关于.net实现不了的功能,怎么办?

我开发一些功能,.net实现不了,但是LIsp可以实现,那我该怎么办?可以在.net中调用LISP么?请教各位大侠!

雪山飞狐_lzh 发表于 2010-4-24 13:25:00

哪些功能?

single-yu 发表于 2010-4-25 21:42:00

版主,你就帮帮我吧,我是在cad06下搞的东西,但是有一个建属性块的时候,就出现致命错误,其他版本的CAD呢,我们这里没有人用
我想弄个.NET中,用LISP把这个功能实现了,我做的程序就缺这一步了!唉!苦恼呀!

single-yu 发表于 2010-4-25 21:49:00

我想着用COM来创建属性块,但是总是搞不好,飞狐版主,你的VBA好,能否教教我呢!
所有点的数据都用.NET得到了,怎么能利用这些数据为每个点创建一个属性块?
能写一段,用COM创建的属性块么?谢了!

雪山飞狐_lzh 发表于 2010-4-25 21:52:00

Cad06建属性快应该没什么问题的,以前做过的
看看你的代码?
另外,代码在其他版本有没问题?
。net调lisp前面的帖子我不是贴过方法了么

single-yu 发表于 2010-4-26 19:21:00


Public Class Class1
   Public Sub CreateBlockWithAttributes()
      Dim db As Database = HostApplicationServices.WorkingDatabase
      Dim blockId As ObjectId = ObjectId.Null
      Dim record As New BlockTableRecord
      record.Name = "RmNum"
      Using trans As Transaction = db.TransactionManager.StartTransaction
            Dim points As New Point3dCollection
            points.Add(New Point3d(-18, -6, 0))
            points.Add(New Point3d(18, -6, 0))
            points.Add(New Point3d(18, 6, 0))
            points.Add(New Point3d(-18, 6, 0))
            Dim pline As New Polyline2d(Poly2dType.SimplePoly, points, 0, True, 0, 0, Nothing)
            record.Origin = points(3)
            record.AppendEntity(pline)
            Dim attdef As New AttributeDefinition
            attdef.Position = New Point3d(100, 200, 0)
            attdef.Height = 8
            attdef.Rotation = 0
            attdef.HorizontalMode = TextHorizontalMode.TextMid
            attdef.VerticalMode = TextVerticalMode.TextVerticalMid
            attdef.Prompt = "Room Number;"
            attdef.TextString = "0000"
            attdef.Tag = "Number"
            attdef.Invisible = False
            attdef.Verifiable = False
            attdef.Preset = False
            attdef.Constant = False
            record.Origin = points(3)
            record.AppendEntity(attdef)
            Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite)
            If bt.Has("RmNum") = False Then
                blockId = bt.Add(record)
                trans.AddNewlyCreatedDBObject(record, True)
                trans.Commit()
            End If
      End Using
    End Sub
End Class平台是Autocad2006 VB.net2005

雪山飞狐_lzh 发表于 2010-4-26 20:00:00

Public Class Class1
    Public Sub CreateBlockWithAttributes()
      Dim db As Database = HostApplicationServices.WorkingDatabase
      Dim blockId As ObjectId = ObjectId.Null
      Using trans As Transaction = db.TransactionManager.StartTransaction
          Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite)
          If bt.Has("RmNum") Then
                     Return
          End If
          Dim record As New BlockTableRecord
          record.Name = "RmNum"
          blockId = bt.Add(record)
          trans.AddNewlyCreatedDBObject(record, True)
          Dim points As New Point3dCollection
          points.Add(New Point3d(-18, -6, 0))
          points.Add(New Point3d(18, -6, 0))
          points.Add(New Point3d(18, 6, 0))
          points.Add(New Point3d(-18, 6, 0))
          Dim pline As New Polyline2d(Poly2dType.SimplePoly, points, 0, True, 0, 0, Nothing)
          record.Origin = points(3)
          record.AppendEntity(pline)
          trans.AddNewlyCreatedDBObject(pline, True)
          Dim attdef As New AttributeDefinition
          attdef.Position = New Point3d(100, 200, 0)
          attdef.Height = 8
          attdef.Rotation = 0
          attdef.HorizontalMode = TextHorizontalMode.TextMid
          attdef.VerticalMode = TextVerticalMode.TextVerticalMid
          attdef.Prompt = "Room Number;"
          attdef.TextString = "0000"
          attdef.Tag = "Number"
          attdef.Invisible = False
          attdef.Verifiable = False
          attdef.Preset = False
          attdef.Constant = False
          record.Origin = points(3)
          record.AppendEntity(attdef)
          trans.AddNewlyCreatedDBObject(attdef, True)
          trans.Commit()
      End Using
   End Sub
End Class

single-yu 发表于 2010-4-26 21:22:00



single-yu 发表于 2010-4-26 21:23:00

还是有错误,这是怎么回事呢?

雪山飞狐_lzh 发表于 2010-4-26 22:00:00

逐步调试下,是那句代码的问题看看
不过代码在2008下没有任何问题
要么是2006下要用特殊的代码顺序写,要么是Bug
页: [1]
查看完整版本: [求助]关于.net实现不了的功能,怎么办?