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

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

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

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

<p>哪些功能?</p><p></p>

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

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

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

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

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

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

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

Public Class Class1
    <CommandMethod("CBWA")> 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

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

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

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

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

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

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