Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

why is this ilogic rule failing

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
swordmaster
472 Views, 6 Replies

why is this ilogic rule failing

For the life of me i cannot understand why this ilogic rule is failing.

It is meant to add a base view to the active drawing at a certain position. The code is almost identical to the SDK samples

 

 

Dim oDrawingDoc As DrawingDocument

oDrawingDoc = ThisApplication.ActiveDocument

 

Dim oSheet As Sheet

oSheet = oDrawingDoc.Sheets.Item(1)

 

Dim oPoint1 As Point2d

oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d (20, 20)

 

Dim oPartDoc As PartDocument

oPartDoc = ThisApplication.Documents.Open("c:\testpart.ipt",False)

 

Dim oBaseView As DrawingView

oBaseView= oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, 1/10,  _

kFrontViewOrientation,kHiddenLineRemovedDrawingViewStyle,)

 

oPartDoc.Close(True)

 

It is failing at the highlighted line

 

Can anyone nudge me in the right direction to get this to work.............thanks

Inventor 2010 Certified Professional
6 REPLIES 6
Message 2 of 7
swordmaster
in reply to: swordmaster

ok figured it out, i have to include the enums in that line

 

oBaseView= oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, 1, ViewOrientationTypeEnum.kFrontViewOrientation,DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle,"Default")

 

So what this appears to do is place the center of the base view on oPoint1

What i want to do is place the bottom left corner of the view at oPoint1...............any ideas how to achieve that?

 

 

thanks

Inventor 2010 Certified Professional
Message 3 of 7
Carthik_Babu
in reply to: swordmaster

hi,
i don't think so...there is any direct code to place view based on bottom left corner to oPoint1.....

(http://forums.autodesk.com/autodesk/attachments/autodesk/120/40065/1/I-Logic%20code.txt)
Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/
Message 4 of 7
VdVeek
in reply to: swordmaster

Swordmaster, a way to do this is by subtract the half baseview width and height from the center position of the view.

I didn't test this code but i copied and modified it from a rule i use.

 

Dim oPoint1 As Point2d

oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d (20, 20)

 

Dim oPartDoc As PartDocument

oPartDoc = ThisApplication.Documents.Open("c:\testpart.ipt",False)

' first place the baseview at (20,20)

 

Dim oBaseView As DrawingView

oBaseView= oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, 1/10,  _

kFrontViewOrientation,kHiddenLineRemovedDrawingViewStyle,)


'Create a new point to move the baseview to.

Dim oBasePosition As Point2d

 

oBasePosition = ThisApplication.TransientGeometry.CreatePoint2d()

oBasePosition.X = 20 - (oBaseView.Width/2)

oBasePosition.Y = 20 - (oBaseView.Height/2)

'Move the baseview to the new position

oBaseView.Position = oBasePosition

 

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 5 of 7
swordmaster
in reply to: VdVeek

Rob,

Thanks for the reply, it makes a lot of sense. I had been thinking somewhat along the same lines. However i was missing oBaseView.width/2 and .height/2

 

Regarding the first point (in the example its 20,20)

Been trying to understand what 20 actually is. Does not seem to be based on the view scale. Any ideas?

 

Inventor 2010 Certified Professional
Message 6 of 7
VdVeek
in reply to: swordmaster

Swordmaster, 20 means 20 centimeters from the left-bottom corner of the drawing sheet in the X or Y direction. The Inventor API uses centimeters.

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.
Message 7 of 7
swordmaster
in reply to: swordmaster

Thanks,

I had completely forgotten that the API used centimetres

thanks

Inventor 2010 Certified Professional

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report