Ilogic (VBA) Rounded lines in sketch

Ilogic (VBA) Rounded lines in sketch

Maciej.Miller
Explorer Explorer
1,254 Views
4 Replies
Message 1 of 5

Ilogic (VBA) Rounded lines in sketch

Maciej.Miller
Explorer
Explorer

Hi everyone
I'm a newbie for ilogic user and I need yours help.
I have a little problem with coding in ilogic (VBA).

How can i rounded two lines in sketch using ilogic rule?

I have a point in Excel
Nr 1 [X,Y]
Nr 2 [X,Y]
...
EOF

f1.JPG

I read this poins and create a line
first line [Nr 1, Nr 2]
second line [Nr 2, Nr 3]
...
etc

f2.JPG

I want doing somting like that:

f4.JPG

My code:

SyntaxEditor Code Snippet

Sub main()
'Sprawdzenie czy szkic jest otwarty.
If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
	MessageBox.Show("A sketch must be active.", "iLogic")
	Return
End If

'set a reference to the active sketch.
Dim Szkic As PlanarSketch
Szkic = ThisApplication.ActiveEditObject

'set a reference to the transient geometry collection.
Dim Geometria As TransientGeometry
Geometria = ThisApplication.TransientGeometry

'========================================================
	
'nazwa_pliku_xlsx = InputBox("Podaj nazwę pliku:", "Nazwa pliku (bez rozszerzenia xlsx)", "Default Entry")
nazwa_pliku_xlsx = "pkt" & ".xlsx"
Adres = ThisDoc.Path & "\" & nazwa_pliku_xlsx

Dim Licznik, i As Integer
i = 1

'Funkcja GoExcel.FindRow znajduje nr wiersza dla EOF (W excelu w Arkuszu 1 musi byc formatowanie jako tabela)
'Licznik pomniejsza j.w. o -1
Licznik = (GoExcel.FindRow(nazwa_pliku_xlsx, "Arkusz1", "LP", "<>", "EOF")) - 1
MessageBox.Show("Licznik=  " & Licznik)
Dim Odcinek(0 To Licznik) As SketchLine
Dim X(0 To 1000), Y(0 To 1000) As Double

Do While i< Licznik-1
	X(i) = (GoExcel.CellValue(nazwa_pliku_xlsx, "Arkusz1", "B" & CStr(i + 2)))/10
	Y(i) = (GoExcel.CellValue(nazwa_pliku_xlsx, "Arkusz1", "C" & CStr(i + 2))) / 10
	
	If i=1
		Odcinek(i) = Szkic.SketchLines.AddByTwoPoints(Geometria.CreatePoint2d(0, 0), Geometria.CreatePoint2d(X(i), Y(i)))
	Else
		Odcinek(i) = Szkic.SketchLines.AddByTwoPoints(Odcinek(i-1).EndSketchPoint, Geometria.CreatePoint2d(X(i), Y(i)))
	End If
	i = i + 1
			
	Loop

GoExcel.Close
iLogicVb.UpdateWhenDone = True

End Sub
	


BR
M. Miller

 

 

 

 

0 Likes
Accepted solutions (2)
1,255 Views
4 Replies
Replies (4)
Message 2 of 5

Xun.Zhang
Alumni
Alumni

Hello M. Miller,

It sounds like can be well-handled by constant Fillet API. @YuhanZhang, any good practice to offer here?

Thanks!


Xun
0 Likes
Message 3 of 5

YuhanZhang
Autodesk
Autodesk
Accepted solution

Add below code lines to your iLogic code:

 

Odcinek(i) = Szkic.SketchLines.AddByTwoPoints(Odcinek(i-1).EndSketchPoint, Geometria.CreatePoint2d(X(i), Y(i)))

' Fillet the two sketch lines
Dim dRadius As Double:dRadius = 5
Szkic.SketchArcs.AddByFillet(Odcinek(i-1),Odcinek(i),dRadius,Odcinek(i-1).StartSketchPoint.Geometry,Odcinek(i).EndSketchPoint.Geometry)


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 4 of 5

YuhanZhang
Autodesk
Autodesk

Can my code solve the problem? If yes please accept it as solution, thanks.



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 5 of 5

Maciej.Miller
Explorer
Explorer
Accepted solution

Hi

Thank You for the solution.
It was very helpful.

0 Likes