Jump to content

Common Insertion Points in VBA


hairyuga

Recommended Posts

Hey,

 

I'm stuck again! I'm trying to find a way to use a common insertion point so that the user doesn't have too. The point of building this panel is to add dimensions and profiles to a block and then hit a "Create Panel" button to build the block. In this instance the user has already choose the dimension to create a box and pick a corner point. Well, I would like to use this corner point from the box as an insertion point for the part reference, text, and symbols (if needed). As you can see, VarPick under cmdCreatePanel is the point I'm trying to reference in for InsertionPnt under cmdWall. Thanks for your help!

 

 

Private Sub cmdWall_Click()
Dim InsertionPnt As Variant
Me.hide
InsertionPnt = ThisDrawing.Utility.GetEntity(varPick)
Dim ampartref As McadPartReference
Set ampartref = ThisDrawing.ModelSpace.AddCustomObject("AcmPartRef")

End Sub
'Combo Box for Panel Sizes
Private Sub UserForm_Activate()
cmbPanelWidth.AddItem "1'-0"""
cmbPanelWidth.AddItem "1'-0 1/2"""
cmbPanelWidth.AddItem "1'-1"
cmbPanelWidth.AddItem "10'-0"
cmbPanelLength.AddItem "10'-0"""
cmbPanelLength.AddItem "10'-0 1/2"""
cmbPanelLength.AddItem "10-1"""
cmbPanelHeight.AddItem "6"""
cmbPanelHeight.AddItem "8"""
cmbPanelHeight.AddItem "10"""
cmbPanelHeight.AddItem "12"""
End Sub


'Create Panel
Private Sub cmdCreatePanel_Click()
Dim varPick As Variant
Dim dblLength As Double
Dim dblWidth As Double
Dim dblHeight As Double
Dim dblCenter(2) As Double
Dim objEnt As Acad3DSolid


Me.hide

'get the input from user
With ThisDrawing.Utility
.InitializeUserInput 1
varPick = .GetPoint(, vbCr & "Pick a corner point: ")
.InitializeUserInput 1 + 2 + 4, ""
dblLength = .DistanceToReal(cmbPanelLength.Text, acEngineering)
.InitializeUserInput 1 + 2 + 4, ""
dblWidth = .DistanceToReal(cmbPanelWidth.Text, acEngineering)
.InitializeUserInput 1 + 2 + 4, ""
dblHeight = .DistanceToReal(cmbPanelHeight.Text, acEngineering)
End With
'calculate center point from input
dblCenter(0) = CDbl(varPick(0)) + (dblLength / 2)
dblCenter(1) = CDbl(varPick(1)) + (dblWidth / 2)
dblCenter(2) = CDbl(varPick(2)) + (dblHeight / 2)

'draw the entity
Set objEnt = ThisDrawing.ModelSpace.AddBox(dblCenter, dblLength, _
dblWidth, dblHeight)
objEnt.History = True
objEnt.Update
ThisDrawing.Regen acActiveViewport
Me.Show
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Link to comment
Share on other sites

Thanks for your reply. I'm new at this. I'm not sure how to refer that point? Get Point is for user input. I want the part reference to automatically insert at that point.

 

Private Sub cmdWall_Click()
Dim InsertionPnt As Variant
Me.hide

'How do I get that insertion point from the corner point from Varpick??????? I want the point the 
user initially picks when they insert the block.

InsertionPnt = ThisDrawing.Utility.GetPoint ()


InsertionPnt = ThisDrawing.Utility.TranslateCoordinates(InsertionPnt, acUCS, acWorld, False)
Dim mpartref As McadPartReference
Set mpartref = ThisDrawing.ModelSpace.AddCustomObject("AcmPartRef")
mpartref.Origin = InsertionPnt
End Sub[

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