Jump to content

AutoCAD VBA or alternative for insert block


jerry00769

Recommended Posts

Hello everybody,

 

I would like to ask you for a help. I am programming some Ribbon menu structure for electrical blocks and lines incl. multilines, multitexts. At the moment I am solving the following problem with the INSERT block VBA statement (only VBA programming, no knowledge with others).

 

There si some code for insterting block (standard):

 

Sub Run_Set_BunkyInteraktivne()
If ThisDrawing.SummaryInfo.Keywords <> "EPS" Then
MsgBox "Toto není šablona EPS, tlačítko z menu nabídky nelze použít!", vbExclamation
Exit Sub
End If

On Error Resume Next
Dim strName As String

strName = EPS_PATH & "Blocks\" & Block_Name & ".dwg"
 

Dim varInsertionPoint As Variant
Dim dblX As Double
Dim dblY As Double
Dim dblZ As Double
Dim dblRotation As Double
Dim objBlockRef As AcadBlockReference

varInsertionPoint = ThisDrawing.Utility.GetPoint(, "Vyber umístění")
dblX = 1 * ThisDrawing.SummaryInfo.Comments / 1000 'měřítko z informace o výkresu
dblY = 1 * ThisDrawing.SummaryInfo.Comments / 1000 'měřítko z informace o výkresu
dblZ = 1 * ThisDrawing.SummaryInfo.Comments / 1000 'měřítko z informace o výkresu
dblRotation = ThisDrawing.Utility.GetAngle(varInsertionPoint, "Vyber úhel")
'zadat manuálně úhel / není interaktivní


Set objBlockRef = ThisDrawing.ModelSpace.InsertBlock(varInsertionPoint, strName, dblX, dblY, dblZ, dblRotation)

End Sub

 

This code works fine, but it is not interactive for rotating an existing block (dwg file) on the screen (see figure 1 and see figure 2 interactive from the insert block manually dialog). Are there any VBA or LSP code sequences or other alternative for instert block dialog with parameters to change automatically?

 

Thanks so much for your feedback in advance.

BR, Jaroslav

image 1.jpg

image 2.jpg

Link to comment
Share on other sites

Using a menu to insert a block choose block, choose point then can DRAG the angle

image.thumb.png.bebb16b660cff0d1b567338045aab3af.png

^c^cINSERT ca3ch-1 DRAG \1;;DRAG

 

From a program prospective a couple of ways insert the block then invoke rotation of the last object, yes 2 steps. But the user wont see it.

 

Another is pick insertion point then ask for a second point in lisp (getpoint pt1 "\nSelect angle ") this draws a dummy line from the insertion point as you search the screen for angle, you then get angle pt1-pt2. But you do not see block.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...