Hello,
Currently i'm working on a set of codes in Ilogic that automate a drawing. But I got stuk on the part where I make the section views.
The work flow is;
- get some workpoints in the baseview (Topview)
- create lines between them
- Make the section views
- (part that does work but not all the way) rotate the section views.
This is where I start with;
This is afther the section views are created;
Afther the rotating the section views are standing upside down or have the direction not in the right way (see picture below);
This is how the direction of the section view should look like but I didn't figure out how to get there.... ( i want it to go counter clockwise);
The code i have for rotating the view is this. maybe you can tweak it or use the variables etc. etc.
Dim oDrawingDocument As DrawingDocument = ThisServer.ActiveDocument Dim oSheet As Sheet = oDrawingDocument.ActiveSheet Dim oView2 As DrawingView = ActiveSheet.View("Aanzicht1").View Dim oAssemblyDoc2 As AssemblyDocument = oView2.ReferencedDocumentDescriptor.ReferencedDocument Dim oOccs2 As ComponentOccurrences oOccs2 = oAssemblyDoc2.ComponentDefinition.Occurrences Dim oOcc2 As ComponentOccurrence For Each oOcc2 In oOccs2 Totaltel = Totaltel + 1 Next Dim oOccs As ComponentOccurrences oSketches = oView2.Sketches 'Variabelen------------------------ Dim Tel As Integer = 1 'als aantal schetsen/views Dim Row As Integer = 4 'Rij voor aantal graden (excel) For Each osketch In oSketches Dim Viewletter As String = Chr(64 + Tel) 'Van getal naar letter (Voor sectionview naam.) Dim oView As DrawingView = ActiveSheet.View(Viewletter).View Dim oAssemblyDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument oOccs = oAssemblyDoc.ComponentDefinition.Occurrences Dim oOcc As ComponentOccurrence Dim Oviewtje As DrawingView 'Oviewtje = oSheet.DrawingViews.Item(2) Oviewtje = ActiveSheet.View(Viewletter).View Dim Degrees As Integer = GoExcel.CellValue("C:\Users\Thomas\Desktop\TANK 3D.xlsx", "Romp", "D" & Row) Degrees = 360 - Degrees + 90 If Degrees > 360 Then Degrees = Degrees - 360 End If rotatie_degrees = (Oviewtje.Rotation / PI * 180) If rotatie_degrees*-1 = Degrees Or rotatie_degrees = Degrees Then Else Oviewtje.RotateByAngle(Degrees * (PI / 180), True) End If 'iLogicVb.RunRule("TESTING_EXTRA") Dim teller As Integer = 1 For Each oOcc In oOccs Dim oComponentOcc As ComponentOccurrence = oAssemblyDoc.ComponentDefinition.Occurrences.Item(teller) If oComponentOcc.Name = "KW-02-00:1" Then xComponentOcc = oComponentOcc.Name.Replace(":1", "") For Each Nozzle1 As Document In oAssemblyDoc.ReferencedDocuments Dim Nozzle2 As String = Nozzle1.DisplayName If Right(Nozzle2,3) = "ipt" Then xNozzle = Nozzle2.Replace(".ipt", "") Else xNozzle = Nozzle2.Replace(".iam", "") End If '' Nozzle = oAssemblyDoc.ReferencedDocuments.Item(2) '' Totaltel = Totaltel - 1 If xNozzle = xComponentOcc Then Nozzle = Nozzle1 End If Next Dim oWorkPoint1 As WorkPoint = Nozzle.ComponentDefinition.WorkPoints.Item(1) oComponentOcc.CreateGeometryProxy(oWorkPoint1, oWorkPointProx1) Oviewtje.SetIncludeStatus(oWorkPointProx1, True) End If teller = teller + 1 Next teller = 1 For Each oOcc In oOccs Dim oComponentOcc As ComponentOccurrence = oAssemblyDoc.ComponentDefinition.Occurrences.Item(teller) xComponentOcc = oComponentOcc.Name.Replace(":1", "") If xComponentOcc = "KW-06-" & Tel Then For Each Nozzle1 As Document In oAssemblyDoc.ReferencedDocuments Dim Nozzle2 As String = Nozzle1.DisplayName If Right(Nozzle2,3) = "ipt" Then xNozzle = Nozzle2.Replace(".ipt", "") Else xNozzle = Nozzle2.Replace(".iam", "") End If '' Nozzle = oAssemblyDoc.ReferencedDocuments.Item(2) '' Totaltel = Totaltel - 1 If xNozzle = xComponentOcc Then Nozzle = Nozzle1 End If Next Dim oWorkPoint2 As WorkPoint = Nozzle.ComponentDefinition.WorkPoints.Item(1) oComponentOcc.CreateGeometryProxy(oWorkPoint2, oWorkPointProx2) Oviewtje.SetIncludeStatus(oWorkPointProx2, True) End If teller = teller + 1 Next '' Tel = Tel + 1 ' If Left(Nozzle.displayname, 5) = "KW-06" Then ' End If ' If Left(Nozzle.displayname, 5) = "KW-02" Then ' Dim oWorkPoint2 As WorkPoint = Nozzle.ComponentDefinition.WorkPoints.Item(1) ' oComponentOcc.CreateGeometryProxy(oWorkPoint2, oWorkPointProx2) ' oView.SetIncludeStatus(oWorkPointProx2, True) ' End If Dim oCenterMark1 As Centermark Dim oCenterMark2 As Centermark Dim oCenterMark As Centermark For Each oCenterMark In oSheet.Centermarks If oCenterMark.Attached Then If oCenterMark.AttachedEntity Is oWorkPointProx1 Then oCenterMark1 = oCenterMark ElseIf oCenterMark.AttachedEntity Is oWorkPointProx2 Then oCenterMark2 = oCenterMark End If End If Next Dim oViewSection As SectionDrawingView 'oViewSection = oSheet.DrawingViews.Item(2) oViewSection = ActiveSheet.View(Viewletter).View If oCenterMark1.Position.X > oCenterMark2.Position.X Then oViewSection.ReverseDirection End If Hoogte_nozzle = GoExcel.CellValue("C:\Users\Thomas\Desktop\TANK 3D.xlsx", "Romp", "F" & Row) If Hoogte_nozzle - Hoogte_nozzle / 4 < oCenterMark2.Position.X*10 And oCenterMark2.Position.X*10 < Hoogte_nozzle + Hoogte_nozzle / 4 Then Else Oviewtje.RotateByAngle(Pie, True) End If Oviewtje.RotateByAngle(Pie, True) oView.SetIncludeStatus(oWorkPointProx1, False) oView.SetIncludeStatus(oWorkPointProx2, False) Tel = Tel + 1 Row = Row + 1 Next
I hope someone could help me and maybe have some fun with it.
Solved! Go to Solution.
Solved by Stakin. Go to Solution.
The only thing that I need to get fixed is that the direction of the section view is in the right way and that the view is rotated like i showed in the pictures above. The rotation part works but not if the direction is reversed....
Hi stakin,
That is indeed what I'm looking for.
I have this rule that makes a section view of every sketch line in the drawing.
Afther running that rule i get the sectionviews but some of them are to the wrong direction. (see picture below)
Green is good direction and purple is the wrong direction.
Now i am trying to change that but first I have to rotate every view. This because that looks much nicer. otherwise it looks like this;
and i want them all to align
And how do you see that? because the section views that i make are in random order.
DrawingViews.AddSectionView( ParentView As DrawingView, SectionLineSketch As DrawingSketch, Position As Point2d, ViewStyle As DrawingViewStyleEnum, [Scale] As Variant, [ShowLabel] As Boolean, [Name] As String, [Reserved] As Boolean, [FullDepth] As Boolean, [SectionDepth] As Variant ) As SectionDrawingView
The placement position determines the view direction.
The placement point is to the left of the section line and the section direction is to the left
Otherwise, vice versa
test it.
That part i'd understand, but how do i know wich one is to the left and to the right? how can i know that coordinates?
You can use the angle between the Y axis of the view and your section line
As your instance,it maybe
Dim oP1 As Point2d ' Section Line Point in the cylinder
Dim oP2 As Point2d 'Section Line Point the cylinder outer point
Dim oP3 As Point2d 'the section view first place position point
Dim oV1 As Vector2d
Dim oV2 As Vector2d
oV1 = ThisApplication.TransientGeometry.CreateVector2d(oP2.X - oP1.X, oP2.Y - oP1.Y)
oV2 = ThisApplication.TransientGeometry.CreateVector2d(0, If(oP1.X=0,1,Sign(oP1.X)))
oV1.AddVector(oV2)
oV1.ScaleBy(0.5)
oP3 = oP1.Copy
oP3.TranslateBy(oV1)
try it,untested,it may be cann't meet your demand
Thankyou for your time,
I will test this next week. im very busy right now. So youll hear from me soon
Try this,
Dim oP1 As Point2d
Dim oP2 As Point2d
Dim oV1 As Vector2d
Dim oV2 As Vector2d
oV1 = ThisApplication.TransientGeometry.CreateVector2d(oP2.X - oP1.X, oP2.Y - oP1.Y)
oV2 = ThisApplication.TransientGeometry.CreateVector2d(0, If(oP2.X=0,IIf(oP2.Y>=0,1,-1),Sign(oP2.X))*oV1.Length)
oV1.AddVector(oV2)
oV1.ScaleBy(0.5)
Dim oP3 As Point2d
oP3 = ThisApplication.TransientGeometry.CreatePoint2d((oP2.X + oP1.X)/2, (oP2.Y + oP1.Y)/2)
oP3.TranslateBy(oV1)
Morning,
Sorry I was occupied untill now, I tested it in a new ilogic rule, but I get the error message; "Object reference not set to an instance of an object."
How do I implement this in my rule?
Dim oP1 As Point2d 'sectionline First point inside the cylinder
Dim oP2 As Point2d 'sectionline second point outside the cylinder
Dim oV1 As Vector2d
Dim oV2 As Vector2d
oV1 = ThisApplication.TransientGeometry.CreateVector2d(oP2.X - oP1.X, oP2.Y - oP1.Y)
oV2 = ThisApplication.TransientGeometry.CreateVector2d(0, If(oP2.X=0,IIf(oP2.Y>=0,1,-1),Sign(oP2.X))*oV1.Length)
oV1.AddVector(oV2)
oV1.ScaleBy(0.5)
Dim oP3 As Point2d
oP3 = ThisApplication.TransientGeometry.CreatePoint2d((oP2.X + oP1.X)/2, (oP2.Y + oP1.Y)/2)
oP3.TranslateBy(oV1)
Add this code snippet to your rule of create section view
Can't find what you're looking for? Ask the community or share your knowledge.