How to set the thickness of a polyline in vb using stand alone program

How to set the thickness of a polyline in vb using stand alone program

Anonymous
Not applicable
1,645 Views
7 Replies
Message 1 of 8

How to set the thickness of a polyline in vb using stand alone program

Anonymous
Not applicable

Hello, I have code to insert a block and explode it. But I'm now wondering how to set the thickness of the polyline afterwards. Here is what I have so far: 

Private Sub InsertBlock(ByVal acadapp As Autodesk.AutoCAD.Interop.AcadApplication, _
                            ByVal acadDoc As Autodesk.AutoCAD.Interop.AcadDocument, _
                            ByVal InsertionPT As Object, _
                            ByVal BlockName As String)

Dim DbxDoc As Object = acadapp.GetInterfaceObject
"ObjectDBX.AxDbDocument.19")
        DbxDoc.Open(BlockDrawing)

Dim Objects(0) As AcadBlock
For Each entry As AcadBlock In CType(DbxDoc.Blocks, IEnumerable)
If (Not entry.IsLayout) AndAlso (Not entry.Name.StartsWith("*")) Then
   Objects(0) = entry
   DbxDoc.CopyObjects(CObj(Objects), acadDoc.Blocks)
End If
Next entry

Dim oBlkRef As AcadBlockReference
oBlkRef = acadDoc.ModelSpace.InsertBlock(InsertionPT, BlockName, 1.0#, 1.0#, 1.0#, 0)
oBlkRef.Explode()

End Sub

 The insert block code was supplied to me by Mikko and works great. Thanks again Mikko. But now I'm trying to relieve the user of another step by setting the thickness of the polyline inserted based upon the insertion point. Any help would be appreciated, Thank you.

0 Likes
Accepted solutions (1)
1,646 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
so you'll probably want a selection set to find all the polys, then poly.constantwidth = x for global width, can also set start and end width indepentely.
0 Likes
Message 3 of 8

Anonymous
Not applicable

But I am trying to set the thickness property, not the width of the polyline.

0 Likes
Message 4 of 8

_gile
Consultant
Consultant

Hi,

 

Do you sometimes have a look at the docs?

 

The Polyline managed class have a Thickness property, so have the COM AcadLWPolyline one (as you're using COM).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 8

Anonymous
Not applicable

I try to look through the help docs, but it's hard to find anything on the out of process commands. With the time it is taking me to try and figure it out, I'm probably going to have to write some AutoLisp programs that I can start from my VB.Net program program using SendCommand. I appreciate the help though.

0 Likes
Message 6 of 8

_gile
Consultant
Consultant
Accepted solution

cncah a écrit :

I try to look through the help docs, but it's hard to find anything on the out of process commands. With the time it is taking me to try and figure it out, I'm probably going to have to write some AutoLisp programs that I can start from my VB.Net program program using SendCommand. I appreciate the help though.


If I do not misunderstand, for your "out of process" program, you're using the COM API (ActiveX Automation library) which is the same as the one used by VBA and Visual LISP. You'd find the docs for this API here:

%ProgramFiles%\Common Files\Autodesk Shared\acadauto.chm

 

Dim plineObj As AcadLWPolyline
Dim thickness As Double

...

plineObj.Thickness = thickness

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 7 of 8

Anonymous
Not applicable

 

Thanks for the tip. I got slammed at work and had to put the project on hold for a couple of days but I looked up the help doc that you suggested and thanks a ton for that! I was able to get the polyline into a selection set and set the thickness and change the layer name just fine. I have a question though, I'm using this to get my selection set:

 

Dim SelSet As Autodesk.AutoCAD.Interop.AcadSelectionSet

SelSet = ACADapp.ActiveDocument.SelectionSets.Add("SelSet")

SelSet.Select(AcSelect.acSelectionSetLast)

 

Would it be better to try and build the selection set by getting the polyline by layer name or is "AcSelect.acSelectionSetLast" good enough for what I am doing? Just trying to make the program bulletproof is all.

0 Likes
Message 8 of 8

_gile
Consultant
Consultant

I see nothing wrong with your code, but I'm not very proficient with COM, I avoid to use it as far as I can.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes