Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sketchline - Set Line Weight to "Default"

13 REPLIES 13
Reply
Message 1 of 14
Tiffany_Hayden_
601 Views, 13 Replies

Sketchline - Set Line Weight to "Default"

This may be a simple question...

 

I am trying to set the sketchline line weight to the "Default" setting in vb.net. But the line weight property is a double. Is there a way to set it to the default a different way? 

 

Tiffany_Hayden__0-1711554673943.png

 

Tiffany_Hayden__2-1711554813111.png

 

 

 

If I use the LineWeightTypeEnum there are only two values and neither is default. 

 

Tiffany_Hayden__1-1711554722291.png

 

 

Just curious if anyone else has ran into this situation. 

 

Thanks in advance! 

Tiffany Hayden
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.

EESignature

13 REPLIES 13
Message 2 of 14

Is this sketch in a model document, or in a drawing?  What you are showing looks like what we see in the 'Document Settings' of a model file, on the Sketch tab.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 14

On second thought...If this were in a model file, I do not know how you would set a SketchLine's LineWeight to a 'default' setting, like what you see in the dialog.  I would assume its default would be zero (or whatever the minimum allowed would be).  There do not appear to be anything like Layers or SketchStyles / LineStyles in the StylesManager in a model.

If it were in a drawing, then I would suggest that the default was set by whatever Layer the geometry was on.  My guess is that they just reuse the same dialog in both places, and the 'default' settings are simply the default values to show in those dialogs, unless something more specific has already been set, and the 'default' settings are primarily for use in drawings.  As far as I recall, the line weights in a model sketch, if set to specific values, will only be used if the Document Settings, Sketch tab settings, are set to DisplayLine Weights = True, and Display True Line Weights is also set to True.  Otherwise they would would just get bundled into the 3 group line weights (by range).  We can access those document settings for the Sketch tab by code, if needed.

 

Edit:  Adding link to SketchSettings object.  You can see the 'Accessed From' documentation on that page.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 14

@WCrihfield  Thanks for this reply. Yes this is in a model, within a sketch. 

Tiffany Hayden
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.

EESignature

Message 5 of 14

Hi @Tiffany_Hayden_ 

Try setting it to 0.001 ( which will be in cm). I think you will see that reset it to default.

p.s. do you have your AU proposal ready to submit next week already? 😀

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

' Check to make sure a sketch is open.
If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
	MsgBox("A sketch must be active.")
	Exit Sub
End If

Dim oSketch As PlanarSketch
oSketch = ThisApplication.ActiveEditObject

Dim oLine As SketchLine
oLine = oSketch.SketchLines.Item(1)

oLine.LineWeight = 0.001

 

Message 6 of 14

@Curtis_Waguespack Okay! I was defaulting to .1 but that was way too large! lol How did you know that that was the default? Since the default doesn't have a value. Just curious! 

 

I'm working on my outline. And I have a few other ideas too I'm batting around. I'm getting there! Hopefully make something that gets picked! lol Never know! 

 

Thanks for your help. 😋

Tiffany Hayden
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.

EESignature

Message 7 of 14


@Tiffany_Hayden_ wrote:

 How did you know that that was the default? Since the default doesn't have a value. Just curious! 

 


 

Ha! I knew you were going to ask me how I knew that! 

 

The truth is I don't really know 🙄 

 

I'm guessing there is probably some other place in the API where we do the same thing but it IS documented for that case... 

 

but in this case, I noticed the datatype was a Double and it just sorta came to me that we'd need to use 0.001 for Default, based purely on some thing I did in the past that I have now forgotten.

 

So tribal knowledge I guess?

 

 

 

 

 

Message 8 of 14

Hey,

I did not read that it was a modelsketch....

But maybe still the idea is valid!

Try this way

 

Dim d As DrawingDocument = ThisDrawing.Document
Dim s As Sheet = d.ActiveSheet
Dim ds As DrawingSketch = s.Sketches.Item(1)
Dim sl As SketchLine = ds.SketchLines.Item(1)
Dim o As ObjectDefaultsStyle = d.StylesManager.ObjectDefaultsStyles.GetEnumerator.Current

MsgBox (sl.LineWeight)
sl.LineWeight = d.StylesManager.ObjectDefaultsStyles.Item(1).SketchGeometryLayer.LineWeight 'REPLACE (1) WITH YOUR DEFAULT STANDARD
s.Update

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 9 of 14

@Curtis_Waguespack I though you were going to say it was your Inventor Guru-ness 🤣🤣🤣

Tiffany Hayden
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.

EESignature

Message 10 of 14

So.... The setting to .001 sets the property back to default but visually the line doesn't change. So I go back into the properties for the line and it is set to default but when I just go into the line weight property and do the dropdown and click on default the lineweight changes in the sketch. It's like the sketchline doesn't know that the line has been changed but it clearly says "Default". Have any of you seen that behavior? I can take a video if that would help. 

Tiffany Hayden
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.

EESignature

Message 11 of 14

@Tiffany_Hayden_ 

I think it's working but the little format display is a bit wonky in that it stays at the last line weight that was used, at least that seems like what I am seeing.

 

Try this:

Create 2 rules as shown with the added line of code to select the line, and then run each rule to toggle between them. I see the line update as expected when running the rules to set it back and forth.

 

Default line

 

 

' Check to make sure a sketch is open.
If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
	MsgBox("A sketch must be active.")
	Exit Sub
End If

Dim oSketch As PlanarSketch
oSketch = ThisApplication.ActiveEditObject

Dim oLine As SketchLine
oLine = oSketch.SketchLines.Item(1)

oLine.LineWeight = 0.001
ThisDoc.Document.SelectSet.Select(oLine)

 

 

Curtis_Waguespack_0-1711666140218.png

 

 

Thick Line

 

 

' Check to make sure a sketch is open.
If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
	MsgBox("A sketch must be active.")
	Exit Sub
End If

Dim oSketch As PlanarSketch
oSketch = ThisApplication.ActiveEditObject

Dim oLine As SketchLine
oLine = oSketch.SketchLines.Item(1)

oLine.LineWeight = 0.1
ThisDoc.Document.SelectSet.Select(oLine)

 

 

Curtis_Waguespack_1-1711666245796.png

 

Message 12 of 14

@Curtis_Waguespack I'll try it out! Thanks! 

Tiffany Hayden
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.

EESignature

Message 13 of 14

In the last week I've learned way too much about the behavior of planar sketchlines. 

 

I thought I would explain my reasoning for anyone coming behind me. 

 

I have noticed that the default on a standard planar sketchline for the lineweight is 0. This is when the value for lineweight is set to default on a brand new line. 

 

I drew a single line in a sketch in a part with the line weight set to "Default" 

 

Tiffany_Hayden__1-1711735840897.png

 

After I drew one line on a sketch in a part I ran this code to find the below information in VBA. 

 

Public Sub GetSketchLine()
    Dim oPartDoc As PartDocument: Set oPartDoc = ThisApplication.ActiveDocument
    Dim oPartDef As PartComponentDefinition: Set oPartDef = oPartDoc.ComponentDefinition
    
    
    Dim oSketch As PlanarSketch: Set oSketch = oPartDef.Sketches(1)
    Dim oSketchline As SketchLine
    
    For Each oSketchline In oSketch.SketchLines
        Debug.Print "here"
    
    Next


End Sub

 

VBA Locals Window 

 

Tiffany_Hayden__0-1711735738251.png

It seems as though the default linewieght should be 0.016, because when I change it to that I compare it to a line existing at default they look the same. 

 

Line at defualt

Tiffany_Hayden__2-1711736102050.png

 

Line at 0.016 in

Tiffany_Hayden__3-1711736117284.png

 

So for my application what I have done is I am checking for lineweight = 0 

 

I'm setting the lineweight to what the equivalent is in cm 0.016 in = 0.4064 cm if the lineweight is set to 0. So that it at least goes back to the normal thickness. If the lineweight is not 0 that means it either has been changed or it came in from a different source like AutoCAD and either way we would want to capture that thickness and return it back. In my situation I want to change the weight to either the same or something thicker to make it noticeable if it came from a different source. So the defaultLineWeight is what we are returning it to and the invSketchLine.LineWeight is what we are changing it to. 

                If invSketchLine.LineWeight = 0 Then
                    defaultLineWeight = 0.04064
                Else
                    defaultLineWeight = invSketchLine.LineWeight
                End If

                invSketchLine.LineWeight = 0.04064 'sketchLine.LineWeight

 

 

I think some changes need to be done to the API because zero should not be the default lineweight when set to "Default". I'm going to add this to an idea posting. 

Tiffany Hayden
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.

EESignature

Message 14 of 14

Created an idea board posting. 

 

https://forums.autodesk.com/t5/inventor-ideas/planar-sketch-sketchline-line-weight-default-value/idi...

Tiffany Hayden
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.

EESignature

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report