Add weld symbols on a drawingview through VBA

Add weld symbols on a drawingview through VBA

Anonymous
Not applicable
2,926 Views
12 Replies
Message 1 of 13

Add weld symbols on a drawingview through VBA

Anonymous
Not applicable

Hello,everyone ! Is there any way to create welds on a drawing ? I'd appreciate it if anyone can give me a hand .

0 Likes
Accepted solutions (2)
2,927 Views
12 Replies
Replies (12)
Message 2 of 13

YuhanZhang
Autodesk
Autodesk

Unfortunately this is still not exposed.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 13

Anonymous
Not applicable

Thank you for your quick replying .En,I've noticed that there're several  API methods about weld symbols in the inventor VBA 'HELP 'file,So I think  there should be some way to add weld symbols through VBA,or some way to make weld symbols display on the drawing .Would you please tell me how to create weld symbols  automatically on the drawing,because my teacher have asked me to deal with something like this ?

 Best regards !

0 Likes
Message 4 of 13

Anonymous
Not applicable

Well,it doesn't matter .Thank you all the same ! It seems that I have to reach the goal with "sketchsymbol" instead .

0 Likes
Message 5 of 13

Anonymous
Not applicable

Hi, I have to come here to ask you for help.,because there is few people replying me if I post my problems on the discussion board . Er,my problem is :How to change the arrow style of sketch symbol with leader .For example,how to change the dots into arrows ?Take  the following code to create a sketch symbol as example .Would you please tell how to change the arrow style ?

 Best wishes to you !

 

sub skech symbol( )

Dim oDoc As DrawingDocument
 Set oDoc = ThisApplication.ActiveDocuments

 Dim oSheet As Sheet
 Set oSheet = oDoc.ActiveSheet
 Dim oTG As TransientGeometry
 Set oTG = oapp.TransientGeometry
 Dim opoint(1 To 4) As Point2d
 Set opoint(1) = oTG.CreatePoint2d(15, 15)
 Set opoint(2) = oTG.CreatePoint2d(10, 10)
 Dim oLeaderPoints As ObjectCollection
 Set oLeaderPoints = oapp.TransientObjects.CreateObjectCollection
 Call oLeaderPoints.Add(opoint(1))
 Call oLeaderPoints.Add(opoint(2))
  
 Dim oSketch As DrawingSketch
 Dim oSketchedSymbolDef As SketchedSymbolDefinition
 Set oSketchedSymbolDef = oDoc.SketchedSymbolDefinitions.Add("Circular")
 Call oSketchedSymbolDef.Edit(oSketch)
 
 Dim oSketchLines(1 To 4) As SketchLine
 Set oSketchLines(1) = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(0, 5), oTG.CreatePoint2d(2.5, 5))
 Set oSketchLines(2) = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(0, 4.8), oTG.CreatePoint2d(2.5, 4.8))
 oSketchLines(2).LineType = kDashedLineType
 Set oSketchLines(3) = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(1, 5), oTG.CreatePoint2d(1, 5.6))
 Set oSketchLines(4) = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(1.5, 5), oTG.CreatePoint2d(1.5, 5.6))
 Call oSketch.GeometricConstraints.AddParallel(oSketchLines(1), oSketchLines(2))
 
  oSketchLines(1).StartSketchPoint.InsertionPoint = True
 
 Call oSketchedSymbolDef.ExitEdit(True)
 Dim oSketchedSymbol As SketchedSymbol
 Set oSketchedSymbol = oSheet.SketchedSymbols.AddWithLeader(oSketchedSymbolDef, oLeaderPoints)

End Sub

 

 

0 Likes
Message 6 of 13

YuhanZhang
Autodesk
Autodesk

Firstly I would recommend that you create different post for different topic:).

 

To change the arrow style you can use the SketchedSymbol.Leader.ArrowheadType.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 7 of 13

Anonymous
Not applicable

Smiley Very HappyFogive my way to post different post for different topic .That's my way to look for you ,hehe .Well,it is effictive indeed . Anyway ,thank you greatly for your kindly replying .I have tried the method you give me ,but I'm warned that it is useless . I‘m a beginner of Inventor  and just use it as follows :

 

 .......

 Dim oSketchedSymbol As SketchedSymbol
 Set oSketchedSymbol = oSheet.SketchedSymbols.AddWithLeader(oSketchedSymbolDef, oLeaderPoints)
 oSketchedSymbol.Leader.ArrowheadType
 .......

 

Would you please give me some advice ? Thank you ahead !Smiley Wink

0 Likes
Message 8 of 13

YuhanZhang
Autodesk
Autodesk
Accepted solution

You need to set it with the proper value you require, like below will set it to a small dot arrow type:

 

oSketchedSymbol.Leader.ArrowheadType = kSmallDotArrowheadType



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 9 of 13

Anonymous
Not applicable

Smiley Very Happy It works smoothly .I can't thank you enough ,Zhang !

0 Likes
Message 10 of 13

Anonymous
Not applicable

Hi,my friend,how are you going these days ? Those days I have posted my problem but there is no one to give me a reply .I have to come here to ask you for help now.

 My problem is how to create a sectionview with Three or more lines through VBA?

 Looking forward to your eraly replying !

Best regards!

0 Likes
Message 11 of 13

Anonymous
Not applicable

I have already known creating sectionview with only one sketchline .The code is as follows:

Dim oPoint2 As Point2d
Set oPoint2 = oapp.TransientGeometry.CreatePoint2d(2, -7)
Dim oPoint3 As Point2d
Set oPoint3 = oapp.TransientGeometry.CreatePoint2d(2, 7)
Dim oPoint4 As Point2d
Set oPoint4 = oapp.TransientGeometry.CreatePoint2d(17.5, 18)

Dim oDrawingSketch As DrawingSketch
Set oDrawingSketch = oView1.Sketches.Add

oDrawingSketch.Edit
Dim oSketchLine As SketchLine
Set oSketchLine = oDrawingSketch.SketchLines.AddByTwoPoints(oPoint2, oPoint3)
oDrawingSketch.ExitEdit

Dim oView2 As SectionDrawingView
Set oView2 = oSheet.DrawingViews.AddSectionView(oView1, oDrawingSketch, oPoint4, kHiddenLineRemovedDrawingViewStyle, , False, " ")

oDrawingSketch.Visible = True

But what I want to do is to create a sectionview with more sketchlines .

0 Likes
Message 12 of 13

YuhanZhang
Autodesk
Autodesk
Accepted solution

Hi,

 

I would recommand to create a new post for different topic so you can draw the attention from more people here as this post has been marked as soluted for another topic:).

 

Though for you current question, you want to create more sketch line segments as section line to create a section view, that you need to create the line segments which are end-to-end connected. Below is sample to create two line segments which are connected and I highlight the code for which you need to pass in to create the new line segment:

 

oDrawingSketch.Edit

 

Dim oSketchLine As SketchLine

Set oSketchLine = oDrawingSketch.SketchLines.AddByTwoPoints(oPoint2, oPoint3)

 

' Create a new line segment, which connects to the above one

Dim oNewLineSeg As SketchLine

Set oNewLineSeg = oDrawingSketch.SketchLines.AddByTwoPoints(oSketchLine.EndSketchPoint, oPoint4)

 

oDrawingSketch.ExitEdit

 

 

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 13 of 13

Anonymous
Not applicable

Smiley Very HappyI know my problem now:

Set oSketchLines(1) = oDrawingSketch.SketchLines.AddByTwoPoints(oPoint2, oPoint3)
Set oSketchLines(2) = oDrawingSketch.SketchLines.AddByTwoPoints(oPoint3, oPoint4)
Set oSketchLines(3) = oDrawingSketch.SketchLines.AddByTwoPoints(oPoint4, oPoint5)

 

OK,I'll follow your advice ! Now my remaiming problem is how to create a local sectionview as attached .I'll post it as a new   topic on the board . Would you please give me a hand if no one reacts ?

0 Likes