Author Topic: Block.AddLine not working..  (Read 2069 times)

0 Members and 1 Guest are viewing this topic.

hardwired

  • Guest
Block.AddLine not working..
« on: March 18, 2008, 12:11:57 PM »
Hi,

Below is a small snippet of code for a project i'm working on, but when i try to run it, the Set Hline2 = FCBlock.AddLine(Hline2STARTPNT, Hline2ENDPNT) line flags an error, saying 'Invalid Procedure or Argument' - why? As far as i can see, its coded as it should be...

Code: [Select]
Option Explicit
Dim FCBlock As AcadBlock 'Block definition for Chart..
Dim FCBlockX As AcadBlockReference 'Insertable block reference for Chart..
Dim FCBlockPNT(0 To 2) As Double 'Insertion point for Chart block..
Dim Hline2, Hline3, Hline4, Hline5, Hline6, Hline7, Hline8, Hline9 As AcadLine 'Horizontal seperator lines between FXs..
Dim Hline2STARTPNT(0 To 2), Hline2ENDPNT(0 To 2) As Double 'Start and End points for Hline..

' Create block definition..
'BlockName = "Fixings_Chart"
FCBlockPNT(0) = 0: FCBlockPNT(1) = 0: FCBlockPNT(2) = 0
Set FCBlock = ThisDrawing.Blocks.Add(FCBlockPNT, "Fixings_Chart")


' Check which FIX2 is present..
If fx2CHK.Value = True Then
Hline2STARTPNT(0) = 0#: Hline2STARTPNT(1) = -10#: Hline2STARTPNT(2) = 0#  'Start point for Hline 2..
Hline2ENDPNT(0) = 90#: Hline2ENDPNT(1) = -10#: Hline2ENDPNT(2) = 0#  'End point for Hline 2..
Set Hline2 = FCBlock.AddLine(Hline2STARTPNT, Hline2ENDPNT)
End If

.....What could be causing it to spaz out? Something i'm overlooking?

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Block.AddLine not working..
« Reply #1 on: March 18, 2008, 12:56:46 PM »
You are combining Dim statements on one line. In VBA any that are not EXPLICITLY set to something are variants, so ONLY HLine9 is being Dim'ed as a Line, all the others are Variants. Break up each one of your Dim statements to one per line, except those that you want as variants.

hardwired

  • Guest
Re: Block.AddLine not working..
« Reply #2 on: March 19, 2008, 06:40:09 AM »
Hi,

Thanks, that's shifted it. I always thought that you could (as long as they were declared as the same type) list all variables in a line like that, but thanks for the insight..