Jump to content

VBA Block selection set


tmccar

Recommended Posts

I was looking at the "VBA and Excel" program on the AfraLisp website and I am trying to code my own application which is based on it. I had a question on this portion of code

[color="red"]Private Sub UserForm_Initialize()
Dim BlkG(0) As Integer
 Dim TheBlock(0) As Variant
 Dim Pt1(0 To 2) As Double
 Dim Pt2(0 To 2) As Double
 'declare local variables
 

 Set acad = GetObject(, "AutoCAD.Application")
 'set reference to AutoCAD
 
 Set doc = acad.ActiveDocument
 'set reference to the drawing
 
 Set ms = doc.ModelSpace
 'set reference to model space
 
 Set ssnew = doc.SelectionSets.Add("TBLK")
 'create a selection set
 
 Pt1(0) = 0: Pt1(1) = 0: Pt1(2) = 0
 Pt2(0) = 3: Pt2(1) = 3: Pt2(2) = 0
 'set up the array
 
 BlkG(0) = 2
 'group code 2 for block name
 
 TheBlock(0) = "MATLIST"
 'the name of the attribute block
 
 ssnew.Select 5, Pt1, Pt2, BlkG, TheBlock
 'get the block [/color]

 

What is the array for? (Pt1(0), Pt1(0) .. etc)

Edited by tmccar
Link to comment
Share on other sites

Firstly you need to read up on how to properly post code on the forum and not simply use copy and paste.

 

There are two arrays Pt1() and Pt2() and each array has 3 elements which are the X,Y,Z coordinates of two points.

Edited by Tyke
Link to comment
Share on other sites

The points are for a window selection 0,0,0 3,3,0

 

This little bit may help note you can get at block attributes by the order of creation you do not need tag name.

Set SS = ThisDrawing.SelectionSets.Add("pit1sel")
SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal

For Cntr = 0 To SS.Count - 1
If SS.Item(Cntr).Name = BLOCK_NAME Then
 
  attribs = SS.Item(Cntr).GetAttributes
  If attribs(0).TextString = pitname Then 

Link to comment
Share on other sites

The points are for a window selection 0,0,0 3,3,0

 

This little bit may help note you can get at block attributes by the order of creation you do not need tag name.

Set SS = ThisDrawing.SelectionSets.Add("pit1sel")
SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal

For Cntr = 0 To SS.Count - 1
If SS.Item(Cntr).Name = BLOCK_NAME Then
 
  attribs = SS.Item(Cntr).GetAttributes
  If attribs(0).TextString = pitname Then 

 

Ok, I get it! Thanks BIGAL

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...