TheSwamp

Code Red => VB(A) => Topic started by: daron on February 21, 2005, 08:04:12 AM

Title: autoload
Post by: daron on February 21, 2005, 08:04:12 AM
I have some vba events that I'd like to run each time I start Autocad. I originally put a call to them in acad.lsp, but each succesive opened drawing, I'd receive a message telling me that they were already loaded. What can I do to avoid this message? Also, I was wondering if someone could help me with finishing this event up?
Code: [Select]
'Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
'   If CommandName = "PLOT" Then
'  Dim AcadDim As AcadDimension
'    Dim SelSet As AcadSelectionSet
'
'    Set SelSet = ThisDrawing.SelectionSets.Add("Dimension")
'
'        For Each AcadDim In SelSet
'            SendCommand "_.draworder" & vbCr & vbCr
'        Next AcadDim
'    End If
'End Sub

What I'm trying to accomplish is moving all dimensions to the back of the draworder before plotting, so there are no extension lines showing up in print that are laid out along a line. Thanks.
Title: autoload
Post by: TR on February 21, 2005, 09:32:06 AM
For the autoloading part look at this:

http://theswamp.org/phpBB2/viewtopic.php?p=40172#40172
Title: autoload
Post by: daron on February 21, 2005, 09:40:42 AM
So, do I put the code in the acad.dvb or can I have the code in different files and call it from there?

P.S. Thanks. I had seen that thread before, but couldn't relocate it.
Title: autoload
Post by: ronjonp on February 21, 2005, 10:28:48 AM
Take a look at this thread:

http://theswamp.org/phpBB2/viewtopic.php?p=47284#47284

I've been using this:

Code: [Select]
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
 Dim XrefLay As AcadLayer
 Dim MvLay As AcadLayer
 Dim ImgLay As AcadLayer
 Dim HatchLay As AcadLayer
 Dim DimLay As AcadLayer
 
 If CLayer <> "" Then
  ThisDrawing.SetVariable "CLAYER", CLayer
  CLayer = ""
 End If


 If (CommandName = "XREF") Then
  CLayer = ThisDrawing.GetVariable("CLAYER")
  Set XrefLay = ThisDrawing.Layers.Add("xref")
  XrefLay.color = acWhite
 If XrefLay.LayerOn = False Then
  XrefLay.LayerOn = True
  ThisDrawing.Regen (acAllViewports)
 End If
 If XrefLay.Freeze = True Then
  XrefLay.Freeze = False
  ThisDrawing.Regen (acAllViewports)
 End If
  ThisDrawing.SetVariable "CLAYER", "xref"
 End If
..........



With these lines in my acad.lsp to load it:

Code: [Select]
(vl-load-com)
(vl-vbaload (findfile "C:/Program Files/AutoCAD Tools/create_lyrs.dvb"))
(vl-vbaload (findfile "C:/Program Files/AutoCAD Tools/acad.dvb"))
(princ)