How create line with block

How create line with block

m09366023695
Enthusiast Enthusiast
507 Views
2 Replies
Message 1 of 3

How create line with block

m09366023695
Enthusiast
Enthusiast

hi

I want to create a line with blocks :

 

 

Function CreateLine(firstPoint, secondPoint)

    Dim StartPoint(0 To 2), insPt(0 To 2) As Double
    Dim MyBlock As AcadBlock
    Dim blockName As String
    Dim EndPoint(0 To 2) As Double
    
   blockName = "masoud"
    
    StartPoint(0) = firstPoint(0)
    StartPoint(1) = firstPoint(1)
    'StartPoint(2) = 0
    
    EndPoint(0) = secondPoint(0)
    EndPoint(1) = secondPoint(1)
    'EndPoint(2) = 0

    'With ThisDrawing.ModelSpace
    '.AddLine StartPoint, EndPoint
    '.Item(.Count - 1).Update
    'End With
    
    'Create a new block
     Set MyBlock = ThisDrawing.Blocks.Add(insPt, blockName)

    'ADD LINES DIRECT ON YOUR BLOCK
    MyBlock.AddLine StartPoint, EndPoint

    'Add the blockreference in model space
    ThisDrawing.ModelSpace.InsertBlock insPt, blockName, 1, 1, 1, 0
End Function

 

 

but I got this error:

invalid procedure call or argument.

 

 

I want to create line with block as I find it with specific name. because user want to delete it.

0 Likes
508 Views
2 Replies
Replies (2)
Message 2 of 3

seabrahenrique
Advocate
Advocate

Hello,

 

The error occurs because the declaration of the "Startpoint" variable in your first line. You did not put a type the variable:

 

Dim StartPoint(0 To 2), insPt(0 To 2) As Double

 

Instead this, try to use this:

 

Dim StartPoint(0 To 2) As Double, insPt(0 To 2) As Double

 

I hope can help u.

0 Likes
Message 3 of 3

Ed__Jobe
Mentor
Mentor

@m09366023695 wrote:

hi

I want to create a line with blocks :

 

but I got this error:

invalid procedure call or argument.

 

I want to create line with block as I find it with specific name. because user want to delete it.


If you get an error, tell us what line causes the error.

 

If you want to prevent users from deleting entities, put them on a locked layer.

objLine.Layer = "lockedLayer"

 

You can also use the LAYLCK command to change the Locked property of the layer that the line is on. Or:

ThisDrawing.Layers(objLine.Layer).Lock = True

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes