乐筑天下

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

[编程交流] VBA help - block insertion

[复制链接]

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 21:57:28 | 显示全部楼层 |阅读模式
Hi There
 
Sorry that this will be such a basic question.  I am not a VBA expert in any way....quite new actually . Running  Autocad Architecure 2014.
 
I have a VBA utility that I have made a special button for. I want this button to insert a dynamic block.
I have WBLOCK'ed the block and it is in a nework folder - no issues here.
 
There  are several other snippets of VBA code that I have found online (even from this forum) and  have tried to modify them to work. I must be doing something wrong, as  it always stumbles within the code or silently sits there doing nothing.
 
I  just want to click this button and my dynamic block (from network)   will be brought into the existing drawing, and the user will select  insert point and direction..... Mouse click...done....block inserted.  Similar action to a block that would be brought from a tool pallette  (but has to be from this VBA utility)
 
Any help would be appreciated.
 
Matt
回复

使用道具 举报

29

主题

519

帖子

477

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
163
发表于 2022-7-6 22:18:27 | 显示全部楼层
Hi Matt,
 
You don't actually need any VBA code to do what you want, a much better way is to use a palette. Put your block on there and just click it to insert it into a drawing. You have far more control over the whole procedure.
 
There's plenty of information available. Look in Michaels Corner on this site, he's written a lot on tool palettes.
 
Ben
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 22:42:47 | 显示全部楼层
Hi Tyke
 
I use and create a lot of tool palettes, and they are awesome and I agree 100% about control. This particular instance of this block needs to come from this VBA utility. It will save the user a bunch of clicking to go to a palette.
It is probably the only exception I have, or i would have put it on a palette.
 
thanks though
 
Matt
 
 
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 23:16:54 | 显示全部楼层
I'm getting there
 
Im sorry for being a VBA dummy ....but I have one more obstacle.
 
 
As it might be simpler to use the sendcommand, i just need help to write it.
I am not a coder by any means....so excuse my lack of knowledge
 
 
 
This code below will place the block in the drawing....great. But it places it (from user point selection), square on the drawing. I want to be able to insert the block and select the direction of the block (rotate) . Most of the time it will be in 90º selections (place on drawing and go either up, down, left or right). I am guessing the sendcommand line will go after the second last line
 
 
I can't get this rotation working at all.....sigh
 
 
 
can anyone help with this lillte snippet here??
 
 
Private Sub cmdProfileinsert_Click()
 
Dim strPath As String
Dim strBlockName As String
Dim objBlock As AcadBlock
Dim entRef As AcadBlockReference
Dim dblPkPt() As Double
   strBlockName = "Profile"
   strPath = "H:\blah\blah\Profile.dwg"
   On Error Resume Next
   Set objBlock = ThisDrawing.Blocks.Item(strBlockName)
   On Error GoTo 0
   If Not objBlock Is Nothing Then objBlock.Delete 'To reinitialize Block from container file
   DbxCopyBlock strBlockName, strPath 'Copy block into ThisDrawing
   dblPkPt = ThisDrawing.Utility.GetPoint(, "Pick insertion Point: ") 'Get insertion point for test insert
   Set entRef = ThisDrawing.ModelSpace.InsertBlock(dblPkPt, "Profile", 1#, 1#, 1#, 0) 'Test insert
 
End Sub
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 12:56 , Processed in 0.373960 second(s), 71 queries .

© 2020-2025 乐筑天下

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