Forgot password?

Create an account!

Forum

« back

RhinoScript – adding dimensions

Messages

Please log in to write a message.

  • 13. Johannes (Jul 01, 2010 22.11):

    nice! i will try...

  • 12. ddelgiu (Jul 01, 2010 11.53):

    Hi Johannes,
    just uploaded :)

    D

  • 11. Johannes (Jun 14, 2010 13.48):

    hi ddelgiu,
    can you upload that script into the vb-script tool section? I just tried it and find it quite useful for quick dimensioning.

    johannes

  • 10. ddelgiu (Jun 14, 2010 13.33):

    Hi Guys,
    I was inspired on your dimension rhinoscript and I wrote this code:

    Call Main()
    Sub Main()

    Rhino.MessageBox "check all lines are exploded and flip direction to change dimension orientation", 0,_
    "First of all"

    Dim arrLine:arrLine=Rhino.GetObjects("select lines",4)
    If isNull (arrLine) Then Exit Sub

    Rhino.AddLayer "DIMENSIONS",RGB(0,255,255)
    Rhino.CurrentLayer "DIMENSIONS"

    Dim Line
    For Each Line In arrLine
    Call dimension(Line)
    Next

    Rhino.MessageBeep 1

    End Sub

    Sub dimension(line)

    Dim arrcurves,arrAngle,a,b,c,point,point2,strp,strq,arrOffsetCurve,arrsPoint, arrEpoint,arrMP,linebeta

    LineBeta=line

    arrMP = Rhino.CurveMidPoint( linebeta)
    arrcurves=Rhino.OffsetCurve (linebeta, arrMP, 1.0)

    Dim curve
    For Each curve In arrcurves

    arrsPoint = Rhino.CurveStartPoint( curve)
    a= Rhino.Pt2Str(arrsPoint)
    arrePoint = Rhino.CurveEndPoint( curve)
    b= Rhino.Pt2Str(arrePoint)
    arrAngle = Rhino.Angle(arrsPoint, arrePoint)

    Dim arrMidPt: arrMidPt = Array( arrepoint(0), arrepoint(1)-1, 0)

    c = Rhino.Pt2Str (arrMidPt )
    rhino.Command "_DimAligned " & a &" "& b &" "& b
    rhino.HideObjects arrcurves

    Next
    End Sub

  • 9. Reno (Nov 17, 2009 00.22):

    I think this will do it.

    Dim arrStartPt  : arrStartPt = Rhino.CurveStartPoint(line)
    Dim arrEndPt    : arrEndPt = Rhino.CurveEndPoint(line)

           
    Dim strStartPt, strEndPt, strDimCommand
    Dim x1, y1, z1, x2, y2, z2, pt1, pt2, pt3
           
    pt1 = Rhino.Pt2Str (arrStartPt)
    pt2 = Rhino.Pt2Str (arrEndPt)
           
    Dim arrMidPt: arrMidPt = Array(arrStartPt(0), arrStartPt(0) + 5, arrStartPt(2))
           
    pt3 = Rhino.Pt2Str (arrMidPt)
           
    Dim strInput: strInput = "_DimAligned " & pt1 &" "& pt2 &" "& pt3
                   
    Call Rhino.Command (strInput)

    If someone has a input on how to dimension in an other view than world view I'm keen to know more about it.

  • 8. isg (Aug 22, 2008 02.59):

    i think you just need to add a space before the "_Enter" command (ie: " _Enter") then it should work!

  • 7. ledisnomad (Aug 21, 2008 22.38):

    Correction: should be

    pt3 = x1 & "," & CStr(arrStartPt(0)+0.65) & "," & z1
  • 6. ledisnomad (Aug 21, 2008 22.35):

    So here is my dimension function so far:

    Function AddDimension(line)
           
            Dim arrStartPt  : arrStartPt = Rhino.CurveStartPoint(line)
            Dim arrEndPt    : arrEndPt = Rhino.CurveEndPoint(line)
           
            Dim strStartPt, strEndPt, strDimCommand 
            Dim x1, y1, z1, x2, y2, z2, pt1, pt2, pt3
           
            x1 = CStr(arrStartPt(0))
            y1 = CStr(arrStartPt(1))
            z1 = CStr(arrStartPt(2))
            pt1 = x1 & "," & y1 & "," & z1
           
            x2 = CStr(arrEndPt(0))
            y2 = CStr(arrEndPt(1))
            z2 = CStr(arrEndPt(2))
            pt2 = x2 & "," & y2 & "," & z2
           
            pt3 = x1 & CStr(arrStartPt(0)+0.65) & z1
                   
            strDimCommand = "_DimAligned " & pt1 & " " & pt2 & " " & pt3 & "_Enter"
           
            Call Rhino.Command(strDimCommand)
           
    End Function

    But it still asks the user for the dimension location even though I have it entered in pt3. This would speed up my annotation script tremendously... I have 465 panels to dimension so making this work would be great.

  • 5. ledisnomad (Aug 21, 2008 21.29):

    Of course! So all I have to do is convert the points to a coordinate string and run rhino.command. Thanks!

  • 4. Hanno (Aug 21, 2008 16.50):

    you can just type the coordinates, e.g.:

    rhino.command "_dim 0,0,0 10,0,0 horizontal 0,5,0"

  • 3. ledisnomad (Aug 21, 2008 15.12):

    Is there a way to simulate a user click to pick points? Then I could use Rhino.Command "_Dim" and enter points as user input.

  • 2. Hanno (Aug 21, 2008 12.02):

    looks like you're right... there are methods to get dimension values and change the dimension style, but it looks like dimensions can only be created by command.

  • 1. ledisnomad (Aug 20, 2008 23.29):

    From the rhinoscript reference, it appears there isn't a way to add dimensions using a script. Am I missing something?