Geometry Intent + Scaled Views + Wonky Leaders

Geometry Intent + Scaled Views + Wonky Leaders

MechMachineMan
Advisor Advisor
1,209 Views
4 Replies
Message 1 of 5

Geometry Intent + Scaled Views + Wonky Leaders

MechMachineMan
Advisor
Advisor

I am getting this result when using .AddWithLeaders with a view that has been scaled (1/2"=1"). It seems that the geometry can't communication between the 2; but if I try modifying the geometry intent points by a scale factor, it always throws an error.

 

sample.PNG

 

 

The basics of the program is: 

 

Dim oDLine As DrawingCurveSegment
Dim oDwgDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oView As DrawingView
Dim oSketch As DrawingSketch
Dim oLine As SketchLine
Dim oSecLine As SketchLine

Dim angle As Double
Dim tailangle As Double

oDLine = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select the LINE")

oSP = oDLine.StartPoint
oEP = oDLine.EndPoint

Dim oV1 As Vector2d
Dim oV2 As Vector2d

If oEP.Y > oSP.Y
	oV1 = ThisApplication.TransientGeometry.CreateVector2d(oEP.X - oSP.X, oEP.Y - oSP.Y)
	oV2 = ThisApplication.TransientGeometry.CreateVector2d(1, 0)
Else
	oV1 = ThisApplication.TransientGeometry.CreateVector2d(oSP.X - oEP.X, oSP.Y - oEP.Y)
	oV2 = ThisApplication.TransientGeometry.CreateVector2d(1, 0)
End If

angle = oV2.AngleTo(oV1)

For Each oView In oDwgDoc.ActiveSheet.DrawingViews
	For Each oSketch In oView.Sketches
		For Each oLine In oSketch.SketchLines
			If Math.Abs(Math.Round(oView.Scale*(oLine.StartSketchPoint.Geometry.X - oLine.EndSketchPoint.Geometry.X),3)) = Math.Abs(Math.Round((oSP.X - oEP.X),3)) And _
				Math.Abs(Math.Round(oView.Scale*(oLine.StartSketchPoint.Geometry.Y - oLine.EndSketchPoint.Geometry.Y),3)) = Math.Abs(Math.Round((oSP.Y - oEP.Y),3))	
				oSecLine = oLine
			End If
		Next
	Next
Next

Dim oTG As TransientGeometry
Dim oGeometryIntent1 As GeometryIntent
Dim oLeaderPoints1 As ObjectCollection
Dim oGeometryIntent2 As GeometryIntent
Dim oLeaderPoints2 As ObjectCollection

   oTG = ThisApplication.TransientGeometry

    oLeaderPoints1 = ThisApplication.TransientObjects.CreateObjectCollection
    oLeaderPoints1.Add(oSP)
    oLeaderPoints1.Add(oSP)
	
    oGeometryIntent1 = oDwgDoc.ActiveSheet.CreateGeometryIntent(oSecLine, oSecLine.StartSketchPoint.Geometry)
    oLeaderPoints1.Add(oGeometryIntent1)
	
	oLeaderPoints2 = ThisApplication.TransientObjects.CreateObjectCollection
    oLeaderPoints2.Add(oEP)
    oLeaderPoints2.Add(oEP)
	
    oGeometryIntent2 = oDwgDoc.ActiveSheet.CreateGeometryIntent(oSecLine, oSecLine.EndSketchPoint.Geometry)
    oLeaderPoints2.Add(oGeometryIntent2)

Any help is greatly appreciated! Thanks.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Accepted solutions (2)
1,210 Views
4 Replies
Replies (4)
Message 2 of 5

adam.nagy
Autodesk Support
Autodesk Support

Hi Justin,

 

Is all OK when adding the leader through the UI?

If so, then as a start you could create one in the UI and then investigate in VBA what properties it has:

http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html

 

Cheers, 



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 5

MechMachineMan
Advisor
Advisor
Accepted solution
Hi Adam!

Sorry, this is outdated. I figured it out. I was adding 2 sets of points to
the AddWithLeader method and it was throwing it off. Using only 1 set of
points with the geometry intent worked for my needs much better. I was
mistaken in thinking I needed points for each leader node even if they were
the same point in space.

Thanks for the response though!

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 4 of 5

adam.nagy
Autodesk Support
Autodesk Support

Glad it's working now 🙂



Adam Nagy
Autodesk Platform Services
0 Likes
Message 5 of 5

MechMachineMan
Advisor
Advisor
Accepted solution

Sorry, my previous reply was a little off; apparently it just needed the geometry intent. Here is the relevant chunk of code:

 

For Each oView In oDwgDoc.ActiveSheet.DrawingViews
	For Each oSketch In oView.Sketches
		For Each oLine In oSketch.SketchLines
			If Math.Abs(Math.Round(oView.Scale*(oLine.StartSketchPoint.Geometry.X - oLine.EndSketchPoint.Geometry.X),3)) = Math.Abs(Math.Round((oSP.X - oEP.X),3)) And _
				Math.Abs(Math.Round(oView.Scale*(oLine.StartSketchPoint.Geometry.Y - oLine.EndSketchPoint.Geometry.Y),3)) = Math.Abs(Math.Round((oSP.Y - oEP.Y),3))	
				oSecLine = oLine
				oCP = oTG.CreatePoint2d(oSketch.Parent.Position.X, oSketch.Parent.Position.Y)
				oSecSP = oTG.CreatePoint2d(oCP.X +oSecLine.StartSketchPoint.Geometry.X*oView.Scale, oCP.Y + oSecLine.StartSketchPoint.Geometry.Y*oView.Scale)
				oSecEP = oTG.CreatePoint2d(oCP.X +oSecLine.EndSketchPoint.Geometry.X*oView.Scale, oCP.Y + oSecLine.EndSketchPoint.Geometry.Y*oView.Scale)
			End If
		Next
	Next
Next

oLeaderPoints1 = ThisApplication.TransientObjects.CreateObjectCollection
oGeometryIntent1 = oDwgDoc.ActiveSheet.CreateGeometryIntent(oSecLine, oSecSP)
oLeaderPoints1.Add(oGeometryIntent1)

oLeaderPoints2 = ThisApplication.TransientObjects.CreateObjectCollection
oGeometryIntent2 = oDwgDoc.ActiveSheet.CreateGeometryIntent(oSecLine, oSecEP)
oLeaderPoints2.Add(oGeometryIntent2)

oS1 = oDwgDoc.ActiveSheet.SketchedSymbols.AddWithLeader(oSSD1,oLeaderPoints1,angle,1,,False,True)
oS1.LeaderVisible = False
oS2 = oDwgDoc.ActiveSheet.SketchedSymbols.AddWithLeader(oSSD,oLeaderPoints2,angle1,1,PromptStrings,False,True)
oS2.LeaderVisible = False

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes