Cancel
Showing results for 
Search instead for 
Did you mean: 

How to Extend 2D line by using VBA Program

Pioneer
Pioneer

Hi Guys,

 

I am unable to continue with the below program. Please help me to complete.

 

below underline code is not working.

 

Private Sub CommandButton1_Click()

Dim application As SolidEdgeFramework.application
Dim documents As SolidEdgeFramework.documents
Dim partDocument As SolidEdgePart.partDocument
Dim refPlanes As SolidEdgePart.refPlanes
Dim profileSets As SolidEdgePart.profileSets
Dim profileSet As SolidEdgePart.profileSet
Dim profiles As SolidEdgePart.profiles
Dim profile As SolidEdgePart.profile
Dim lines2d As SolidEdgeFrameworkSupport.lines2d
Dim line1 As SolidEdgeFrameworkSupport.Line2d
Dim line2 As SolidEdgeFrameworkSupport.Line2d

application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.application)
documents = application.documents
partDocument = CType(documents.Add("SolidEdge.PartDocument"), SolidEdgePart.partDocument)
refPlanes = partDocument.refPlanes
profileSets = partDocument.profileSets
profileSet = profileSets.Add()
profiles = profileSet.profiles
profile = profiles.Add(refPlanes.Item(1))
lines2d = profile.lines2d

line1 = lines2d.AddBy2Points(0, 0, 0.1, 0)
line2 = lines2d.AddBy2Points(0.05, 0.1, 0.05, 0.15)

 

'Extend Line2 to meet Line1


line2.Extend(0.02, 0.1, line1) 

End Sub

5 REPLIES

Re: How to Extend 2D line by using VBA Program

Pioneer
Pioneer

Hi @Naveen10

 

replace this line: line2.Extend(0,-1,line1)

 

first two argument is releated  to direction.While using exted or trim command give the exact direction.

 

~VPJ

 

Re: How to Extend 2D line by using VBA Program

Pioneer
Pioneer

Hi @VPJ19

I am geeting Error

Error_Extend.PNG

Re: How to Extend 2D line by using VBA Program

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

I think you have to preceed the line with Call or remove the brackets ()

Re: How to Extend 2D line by using VBA Program

Pioneer
Pioneer

Hi @Naveen10

 

Actually, I had checked this API in C# and its work perfectly. You can convert into VB.

 

 

 SolidEdgeFramework.Application appl = null;
SolidEdgeFramework.Documents doc = null;
SolidEdgePart.PartDocument pDoc = null;

appl = SolidEdgeCommunity.SolidEdgeUtils.Connect(true,true); doc = appl.Documents;
pDoc = (PartDocument)doc.Add("SolidEdge.PartDocument"); RefPlane topPln = pDoc.RefPlanes.Item(1); RefPlane rightPln = pDoc.RefPlanes.Item(2); RefPlane frontPln = pDoc.RefPlanes.Item(3); Profiles profs = pDoc.ProfileSets.Add().Profiles; Profile prof = profs.Add(topPln); Line2d line1 = prof.Lines2d.AddBy2Points(0, 0, 0.1, 0); Line2d line2 = prof.Lines2d.AddBy2Points(0.05, 0.1, 0.05, 0.15); line2.Extend(0,- 1, line1); prof.End(ProfileValidationType.igProfileClosed);

 

Re: How to Extend 2D line by using VBA Program

Pioneer
Pioneer

Hi @Tushar

 

Thanks for the reply.

 

Still it is not working