乐筑天下

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

[编程交流] plot x,y and z coordinate usin

[复制链接]

15

主题

41

帖子

26

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 15:03:06 | 显示全部楼层 |阅读模式
how to plot x,y,z coordinates using autocad VB...can someone give me the script plss
 
email me at red_wing86@yahoo.com or add me as ur friend using yahoo massenger
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:10:53 | 显示全部楼层
It would be better if the answer was posted on the forums, as other users could benefit from the code provided
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:15:04 | 显示全部楼层
When you say
what do you mean exactly? 
print coordinates of certain objects to external files? i.e. coords of points to text or excel files...
 
Could you please explain further
 
Thanks
 
Lee
回复

使用道具 举报

48

主题

1073

帖子

1043

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
238
发表于 2022-7-6 15:20:03 | 显示全部楼层
I assumed the OP wanted a plot window.
 
I didn't reply as I didn't have an answer but I did manage to stop myself posting saying answers should be posted in forum. Now you've done that I can agree.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:24:20 | 显示全部楼层
A plot window...
 
maybe something using EXTMIN and EXTMAX?
回复

使用道具 举报

15

主题

41

帖子

26

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 15:27:15 | 显示全部楼层
 
coordinate from excel or txt file..plot to autocad using visual basic..
can someone teach me...thanks
回复

使用道具 举报

0

主题

3

帖子

3

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 15:30:58 | 显示全部楼层
This is my first post and it may or may not be what you're after. I suggest you read and try to understand the code as my error handling here is not the best. I have a user form for picking the file and blocks (which are passed to the routines below) but I can't see how to attach anything here.
 
The following code will place blocks at coordinates read from a csv text file (x,y,z,name or x,y,name - your could change the column order easily if you wanted, I just haven't got around to it). The 'name' will be placed if the specified block has an attribute.
 
The block you want to use must exist within the dwg.
 
The file format is a csv file of either 4 columns (x,y,z,name) or 3 columns(x,y,name).
 
Make sure no coordinates are missing.
 
For 'x,y,name' a z value of 0 is assumed.
 
 
  1. Public mstrBlockName As StringPublic blnBlockLabelFailure As BooleanPublic mstrImportType As StringPublic Sub ReadXYFile(strFileName As String)'mstrBlockName was set on userform before calling this sub routineDim myFile As IntegerDim lngIndex As LongDim strTextLine As StringDim arrText As VariantDim intCol As IntegerDim intSubStrings As IntegerDim dblX As DoubleDim dblY As DoubleDim dblZ As DoubleDim strName As String'strFileName = "C:\GIS\COORD_TEST3.csv" 'change this to your fileOn Error GoTo ErrorHandlerPoint' TODO: Take this check out, have already checked on form.If Dir(strFileName) = "" ThenCall MsgBox(strFileName & " not found", vbExclamation, "Import XYZ Coordinates")GoTo TidyUpAndExitEnd IfmyFile = FreeFileOpen strFileName For Input As #myFileDo While Not EOF(myFile)Line Input #myFile, strTextLinearrText = Split(strTextLine, ",")If lngIndex = 0 Then ' read first line to determine number columns in fileintSubStrings = UBound(arrText)'Debug.Print intSubStringsIf intSubStrings = 2 Then 'i.e. 3 columns, we are expecting X,Y,NamemstrImportType = "XYName"ElseIf intSubStrings = 3 Then 'i.e. 4 columns, we are expecting X,Y,Z and NamemstrImportType = "XYZName"ElsemstrImportType = ""Call MsgBox("The chosen file was invalid." & _vbCrLf & "" & _vbCrLf & "File must comprise 3 (X,Y,Name) or 4 (X,Y,Z,Name) columns of data only.", vbExclamation, "Import XYZ Coordinates")GoTo TidyUpAndExitEnd IfEnd If'if the columns are in the wrong order a type mismatch error will be thrown by the error handlerSelect Case mstrImportTypeCase "XYName"dblX = arrText(0)dblY = arrText(1)dblZ = 0strName = arrText(2)Call InsertBlock(dblX, dblY, dblZ, strName)Case "XYZName"dblX = arrText(0)dblY = arrText(1)dblZ = arrText(2)strName = arrText(3)Call InsertBlock(dblX, dblY, dblZ, strName)Case Else'????????????End SelectlngIndex = lngIndex + 1LoopTidyUpAndExit:'**** tidy up e.g. close and set objects to nothingClose myFileExit SubErrorHandlerPoint:MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ReadXYFile"'could try to catch specific error, e.g possible type mismatch and provide meaningful messageGoTo TidyUpAndExitEnd SubSub InsertBlock(xx As Double, yy As Double, zz As Double, bAttr As String)Dim insertionPnt(0 To 2) As DoubleDim blockRefObj As AcadBlockReferenceDim varAttribs As VariantDim intAttribCount As Integer'Coordinate 'x=0,y=1,z=2insertionPnt(0) = xx#: insertionPnt(1) = yy#: insertionPnt(2) = 0'InsertBlock inserts a drawing file or a named block that has been defined in the current drawing.Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, mstrBlockName, 1#, 1#, 1#, 0)' Get attribute value(s) from the block.varAttribs = blockRefObj.GetAttributes'Check how many attributes the block - if 0 set a boolean flagintAttribCount = UBound(varAttribs)If intAttribCount = -1 Then ' The block has no attributesblnBlockLabelFailure = True'Call MsgBox("The chosen block has no attributes to label.", vbInformation, "Import XYZ Coordinates")Else' We will use only the First attribute in the block found at location Zero.' varAttribs(0) is the first block attribute value.' Note, most programs uses Zero-based counting & therefore the first number is Zero when counting rather than one.varAttribs(0).TextString = bAttr' Update the block so we can see the new Values applied to the block attribute values above.' This is similar to a localized regen, only the block is updated/regenerated.varAttribs(0).UpdateEnd IfTidyUpAndExit:'**** tidy up e.g. close and set objects to nothingExit SubErrorHandlerPoint:MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure InsertBlock"'could try to catch specific error, e.g possible type mismatch and provide meaningful messageGoTo TidyUpAndExitEnd Sub
回复

使用道具 举报

15

主题

41

帖子

26

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 15:37:18 | 显示全部楼层
thankssssss dvhardy...i will try it..
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:41:41 | 显示全部楼层
dvhardy, would you be able to post your code in future within
  1. [/ code] tags as it makes it easier to read, follow and copy  
  2. Thanks
  3.  
  4. Lee
回复

使用道具 举报

15

主题

41

帖子

26

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 15:42:55 | 显示全部楼层
can someone teach me how to class the layer according to height range using visual basic or lips..thanks..
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 21:22 , Processed in 0.447577 second(s), 72 queries .

© 2020-2025 乐筑天下

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