IDW ilogic reference point error

IDW ilogic reference point error

filip
Contributor Contributor
387 Views
3 Replies
Message 1 of 4

IDW ilogic reference point error

filip
Contributor
Contributor

Hi,

 

I have an issue with an .idw where im trying to work out a rule in iLogic that will scale my views depending on the length of a pipe that i have drawn. An example is that if the length is above 7000mm the scale is 1:55, and above 11000 the scale is 1:75 . 

I have four views, the 3 normal ISO standard views + a 3D.

the code i have now gives me the error: "Object reference not set to an instance of an object."

 

Im assuming its the .SetSpacingToCorner code that gives me the error, and this feature is not important, i just need them splitted apart. 

 

here is the code:

 

SyntaxEditor Code Snippet

If Parameter("15231.10:1", "Conveyor_Lenght")<=7000
ActiveSheet.View("VIEW1").Scale=1/45
ActiveSheet.View("VIEW3").Scale=1/55
ActiveSheet.View("VIEW5").Scale=1/55
ActiveSheet.View("VIEW1").SetSpacingToCorner(20, 80, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW2").SetSpacingToCorner(230, 90, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW3").SetSpacingToCorner(280, 40, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW5").SetSpacingToCorner(280, 90, SheetCorner.BottomLeft)

Else If Parameter("15231.10:1", "Conveyor_Lenght")<=11000
ActiveSheet.View("VIEW1").Scale=1/65
ActiveSheet.View("VIEW3").Scale=1/75
ActiveSheet.View("VIEW5").Scale=1/65
ActiveSheet.View("VIEW1").SetSpacingToCorner(20, 80, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW2").SetSpacingToCorner(230, 90, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW3").SetSpacingToCorner(280, 40, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW5").SetSpacingToCorner(280, 90, SheetCorner.BottomLeft)

Else If Parameter("15231.10:1", "Conveyor_Lenght")<=15000
ActiveSheet.View("VIEW1").Scale=1/85
ActiveSheet.View("VIEW3").Scale=1/95
ActiveSheet.View("VIEW5").Scale=1/85
ActiveSheet.View("VIEW1").SetSpacingToCorner(20, 80, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW2").SetSpacingToCorner(230, 90, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW3").SetSpacingToCorner(280, 40, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW5").SetSpacingToCorner(280, 90, SheetCorner.BottomLeft)

End If

    ' Set a reference to the active drawing document
    Dim oDoc As DrawingDocument
 oDoc = ThisDoc.Document


    ' Set a reference to the active sheet
    Dim oSheet As Sheet
 oSheet = oDoc.ActiveSheet

    Dim oDrawingDim As DrawingDimension

    ' Iterate over all dimensions in the drawing and
    ' center them if they are linear or angular.

    For Each oDrawingDim In oSheet.DrawingDimensions
        If TypeOf oDrawingDim Is LinearGeneralDimension Or _
           TypeOf oDrawingDim Is AngularGeneralDimension Then
        oDrawingDim.CenterText
        End If
    Next

InventorVb.DocumentUpdate() 

 Any help?

 

Thank you in advance. 

 

-A

0 Likes
388 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor

 

See my signature for some documentation on debugging manually in iLogic.

 

Also, "lenght" vs "length".

 

Select Case Parameter("15231.10:1", "Conveyor_Length")
Case <=7000 ActiveSheet.View("VIEW1").Scale=1/45 ActiveSheet.View("VIEW3").Scale=1/55 ActiveSheet.View("VIEW5").Scale=1/55 Case <=11000 ActiveSheet.View("VIEW1").Scale=1/65 ActiveSheet.View("VIEW3").Scale=1/75 ActiveSheet.View("VIEW5").Scale=1/65 Case <=15000 ActiveSheet.View("VIEW1").Scale=1/85 ActiveSheet.View("VIEW3").Scale=1/95 ActiveSheet.View("VIEW5").Scale=1/85 End Select
ActiveSheet.View("VIEW1").SetSpacingToCorner(20, 80, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW2").SetSpacingToCorner(230, 90, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW3").SetSpacingToCorner(280, 40, SheetCorner.BottomLeft)
ActiveSheet.View("VIEW5").SetSpacingToCorner(280, 90, SheetCorner.BottomLeft)

Dim oDoc As DrawingDocument oDoc = ThisDoc.Document Dim oSheet As Sheet oSheet = oDoc.ActiveSheet Dim oDrawingDim As DrawingDimension For Each oDrawingDim In oSheet.DrawingDimensions If TypeOf oDrawingDim Is LinearGeneralDimension Or _ TypeOf oDrawingDim Is AngularGeneralDimension Then oDrawingDim.CenterText End If Next InventorVb.DocumentUpdate()

--------------------------------------
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
Message 3 of 4

filip
Contributor
Contributor

Hi Again,

 

I still get the error:

 

 

Error in rule: Rule0, in document: 15231.30.idw

Object reference not set to an instance of an object.

0 Likes
Message 4 of 4

filip
Contributor
Contributor

The Code below gave me the error code:

 

System.NullReferenceException: Object reference not set to an instance of an object.
at iLogic.CadAssemblyUtil.FindComponentOccurrence(Document rootDoc, Object compoName, Boolean topLevelOnly, Boolean inTopLevelContext)
at iLogic.CadCompoOrDoc..ctor(Document rootDoc, Object oName)
at iLogic.ParamDynamicFinder.GetParameterInCompoOrDoc(Object compoOrDocName, String paramName)
at iLogic.ParamDynamic.get_Item(Object compoOrDocName, String paramName)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

SyntaxEditor Code Snippet

Select Case Parameter("15231.10:1", "Conveyor_Length")
    Case <=7000
        ActiveSheet.View("VIEW1").Scale=1/45
        ActiveSheet.View("VIEW3").Scale=1/55
        ActiveSheet.View("VIEW5").Scale=1/55
    Case <=11000
        ActiveSheet.View("VIEW1").Scale=1/65
        ActiveSheet.View("VIEW3").Scale=1/75
        ActiveSheet.View("VIEW5").Scale=1/65
    Case <=15000
        ActiveSheet.View("VIEW1").Scale=1/85
        ActiveSheet.View("VIEW3").Scale=1/95
        ActiveSheet.View("VIEW5").Scale=1/85
End Select

 When removed the code worked just fine, just without the parameter based scaling.

 

0 Likes