29 | 03 | 2017

Divide Entity

Code below lets you select a entity and will then divide the entity into a required number of peaces.

 [code]

Sub DivideEntity()
 
Dim selectionSet As AcadSelectionSet
Dim entity As AcadEntity
Dim eHandle As String
Dim Str1 As String
Dim CommandStr As String
Dim NoOfPeaces As Double
 
'Specify the pint (node) shape
ThisDrawing.SetVariable "PDMODE", 3
 
'Delete the selection set if already exists
For Each selectionSet In ThisDrawing.SelectionSets
 If selectionSet.Name = "DivideSS" Then
  selectionSet.Delete
  Exit For
 End If
Next selectionSet
 
'Create a selection set
Set selectionSet = ThisDrawing.SelectionSets.Add("DivideSS")
selectionSet.SelectOnScreen
 
'Divide each entitity
For Each entity In selectionSet
 eHandle = entity.Handle
 Str1 = "(handent """ + eHandle + """" + ")"
 CommandStr = "_DIVIDE "
 NoOfPeaces = 10 'No of peaces to divide the object into
 
 
 CommandStr = CommandStr & Str1 & vbCr & NoOfPeaces & vbCr
 
 'You can also use the block option. To do so change the code above to:
 'Blockname ="myblock"
 'CommandStr = CommandStr & Str1 & vbCr & "_blo" & vbCr & Blockname & vbCr & "_Yes" & vbCr & NoOfPeaces & vbCr
 
 ThisDrawing.SendCommand (CommandStr) 'Send the command to divide the entity
Next
 
End Sub
 
[/code]
 
The PDMODE can be changed to other pointers as shown below:
 
 
 
 
'Pointer Styles'
 
'Result of the code above, a divided circle'
Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2211966
Latest Articles