LineGraphics.LineWeight capped to 4 px

LineGraphics.LineWeight capped to 4 px

FRFR1426
Collaborator Collaborator
585 Views
6 Replies
Message 1 of 7

LineGraphics.LineWeight capped to 4 px

FRFR1426
Collaborator
Collaborator

The following code should draw a 1 cm width line:

 

 

Public Sub MyLine()
    Dim clientId As String
    clientId = "{2E2EA04D-C12D-4280-BAE3-8ED9DC7DFFA0}"
    Dim graphics As ClientGraphics
    On Error Resume Next
    ThisDocument.ComponentDefinition.ClientGraphicsCollection(clientId).Delete
    On Error GoTo 0
    Set graphics = ThisDocument.ComponentDefinition.ClientGraphicsCollection.Add(clientId)
    Dim node As GraphicsNode
    Set node = graphics.AddNode(1)
    On Error Resume Next
    ThisDocument.GraphicsDataSetsCollection(clientId).Delete
    On Error GoTo 0
    Dim dataSets As GraphicsDataSets
    Set dataSets = ThisDocument.GraphicsDataSetsCollection.Add(clientId)
    Dim coordSet As GraphicsCoordinateSet
    Set coordSet = dataSets.CreateCoordinateSet(1)
    Dim coords(5) As Double
    coords(0) = 0: coords(1) = 0: coords(2) = 0: coords(3) = 1: coords(4) = 1: coords(5) = 1
    coordSet.PutCoordinates coords
    Dim lineGraphPrimitive As LineGraphics
    Set lineGraphPrimitive = node.AddLineGraphics()
    lineGraphPrimitive.LineWeight = 1
    lineGraphPrimitive.LineDefinitionSpace = kModelSpace
    lineGraphPrimitive.CoordinateSet = coordSet
    ThisDocument.Views(1).Update
End Sub

But the LineWeight is not taken in account. In fact, even with LineDefinitionSpace at kScreenSpace, the line weight does not always match the value set. It seems that the line weight is capped to 4 px.

 

 

2017-04-27_141815.png

 

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Accepted solutions (1)
586 Views
6 Replies
Replies (6)
Message 2 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi Maxence,

 

 

There is a huge difference between kScreenSpace and kModelSpace of LineDefinitionSpace.

 

If LineDefinitionSpace is set to kScreenSpace, mentioned LineWeight would be in pixels. So, it is completely depends on resolution of screen (Displaying Monitor). More the resolution of screen, visibility of line would be smaller for the same LineWeight and vice versa.

 

If LineDefinitionSpace is set to kModelSpace, mentioned LineWeight would in default / model units (Centimeters). It does not vary at all on resolution of screen.

 

For this reason, LineWeight is showing difference for kScreenSpace and kModelSpace. Meanwhile, the visibility of line graphics also differs.

 

Please feel free to contact if there is any doubt.

 

If solves your problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 7

FRFR1426
Collaborator
Collaborator

If I use kModelSpace, when I zoom in, the line should be thicker. It's how I understand model space.

 

What you're telling me for kModelSpace is the definition of device-independent pixels. And if I increase the value in kScreenSpace or in kModelSpace, the line should be thicker on screen. It does not go further than 4 px.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 4 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi Maxence,

 

Please find the following VBA code with 2 lines having different line weights. After running this code, lines will have different thickness as shown below.

 

Different line wieght.jpg

 

This shows that on increasing line weight in kScreenSpace, thickness also increases.

 

Sub main()

    Dim clientId As String
    clientId = "2E2EA04D-C12D-4280-BAE3-8ED9DC7DFFA0"
    
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim compDef As PartComponentDefinition
    Set compDef = oDoc.ComponentDefinition
    
    Dim graphics As ClientGraphics
    On Error Resume Next
    compDef.ClientGraphicsCollection(clientId).Delete
    On Error GoTo 0
    Set graphics = compDef.ClientGraphicsCollection.Add(clientId)
    
    Dim node As GraphicsNode
    Set node = graphics.AddNode(1)
    
    On Error Resume Next
    oDoc.GraphicsDataSetsCollection(clientId).Delete
    On Error GoTo 0
    Dim dataSets As GraphicsDataSets
    Set dataSets = oDoc.GraphicsDataSetsCollection.Add(clientId)
    
    Dim coordSet As GraphicsCoordinateSet
    Set coordSet = dataSets.CreateCoordinateSet(1)
    
    Dim coords(5) As Double
    coords(0) = 0: coords(1) = 0: coords(2) = 0: coords(3) = 1: coords(4) = 1: coords(5) = 1
    coordSet.PutCoordinates coords
    
    Dim lineGraphPrimitive As LineGraphics
    Set lineGraphPrimitive = node.AddLineGraphics()
    lineGraphPrimitive.LineWeight = 4
    lineGraphPrimitive.LineDefinitionSpace = kScreenSpace
    lineGraphPrimitive.CoordinateSet = coordSet
    
    Dim coordSet1 As GraphicsCoordinateSet
    Set coordSet1 = dataSets.CreateCoordinateSet(2)
    
    Dim coords1(5) As Double
    coords1(0) = 1: coords1(1) = 1: coords1(2) = 1: coords1(3) = 2: coords1(4) = 1: coords1(5) = 1
    coordSet1.PutCoordinates coords1
    
    Dim lineGraphPrimitive1 As LineGraphics
    Set lineGraphPrimitive1 = node.AddLineGraphics()
    lineGraphPrimitive1.LineWeight = 6
    lineGraphPrimitive1.LineDefinitionSpace = kScreenSpace
    lineGraphPrimitive1.CoordinateSet = coordSet1
    
    Call ThisApplication.Views.Item(1).Update
    Call ThisApplication.ActiveView.Fit
    
End Sub

Please feel free to contact if there is any doubt.

 

If solves your problem, click on "Accept as solution" / give a "kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 7

FRFR1426
Collaborator
Collaborator

I've taken your code and I've only changed the coordinates in order to align the lines.

 

2 px & 4 px: OK

 

2-4.png

 

4 px & 8 px : I don't get the expected result. The 8 px line stays at 4 px:

 

4-8.png

 

And with kModelSpace, always 4px, LineWeight has no effect:

 

modelspace.png

 

There is also kHybridSpace: always 2px wide...

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 6 of 7

FRFR1426
Collaborator
Collaborator

I'm gonna do draw my thick lines myself with triangle primitives.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 7 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi Maxence,

 

That's nice idea!!!!

 

Inventor, Line weight of Line Graphics is limited from 1 px to 4 px.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes