.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
cncah
1260 Views, 7 Replies

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

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.

7 REPLIES 7
Message 2 of 8
conormccartney3897
in reply to: cncah

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.
Message 3 of 8
cncah
in reply to: conormccartney3897

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

Message 4 of 8
_gile
in reply to: cncah

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

Message 5 of 8
cncah
in reply to: _gile

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.

Message 6 of 8
_gile
in reply to: cncah


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

Message 7 of 8
cncah
in reply to: _gile

 

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.

Message 8 of 8
_gile
in reply to: cncah

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost