Send SLINE command from .net code with Style parameter

Send SLINE command from .net code with Style parameter

laurent.cadfr
Contributor Contributor
1,311 Views
3 Replies
Message 1 of 4

Send SLINE command from .net code with Style parameter

laurent.cadfr
Contributor
Contributor

I am using VB.net customization for Plant3D-PnID 2018 (used in PnID context)

 

For a specific purpose I'm intending to use SLINE command from a vb.net application.
First I'm getting a number of information related to user operation.
Then, I want the user to trace a SLINE having a LineStyle got from specific rule (from another part of code)

 

The issue is I do not manage to run SLINE command using a SendStringToExecute with relevant style parameter...

 

Using the same function as below with no parameters actually works but with wrong style (uses the current one, set from previous commands)


I observed that when using SLINE command manually from Editor panel,
it appears from Editor messages that the "Current sline style" is known prior to enter Command:
>Command: SLINE
>Command:
>Current sline style: FB_Pneumatic

this info is shared at the project level (same value in all opened drawings, and saved with project)

So, I guess another method compared to use parameters from SendStringToExecute()
would be to access this information ("Current sline style") and set it to my selection value prior to start my SendStringToExecute()


But, I could not find any system Variable nor API function to access such "Current sline style" information

To date I've not been successful in any of both methods.

 

Am I missing something? Any suggestion?

 

Thanks in advance for help

 

Here is the function vb.net code:

 

Private Function ExecuteMyTool(Byval SelectedStyleName as string) as boolean

  Dim FunctionStatus as Boolean = False

  Try
    ' Init Helper class (retrieve current active Doc, Database...) 
    Helper.Initialize()

    ' Give focus to Working Space
    Helper.ActiveDocument.Window.Focus()

    ' My utility Function to get First Point from User input
    Dim StartPoint As Point3d = AutoCadUtilities.GetPoint("Enter Start Point for SLine: ")

    ' Exit if invalid input from user or cancel
    If StartPoint = Nothing Then Exit Try

    Dim strStartPoint As String = StartPoint.X & "," & StartPoint.Y & "," & StartPoint.Z

    Dim StringToExecute As String = "._" + "SLINE" + " " + SelectedStyleName + " " + strStartPoint + " "

    Helper.ActiveDocument.SendStringToExecute(StringToExecute, False, False, False) 

    ' Success
    FunctionStatus = True

  Catch ex As Exception
    MsgBox("Error in ExecuteMyTool: " & ex.Message, MsgBoxStyle.Critical, "Error")

  Finally
    ' Clean up Helper
    Helper.Terminate()
  End Try

  Return FunctionStatus

End Function

 

0 Likes
1,312 Views
3 Replies
Replies (3)
Message 2 of 4

laurent.cadfr
Contributor
Contributor

As I got no reply while continuing my investigations, I finally rebuilt my own SLINE command based on a jig polyline, using then the jig vertices as parameters to a AddSline function inspired by the Plant3D SDK samples.

 

Improving my solution I came to another issue:

Now I would like to convert the SLine from set of straight segments to a set of lines and arcs (rounded corners polyline)

It was quite straightforward to set the jig with rounded corners using The "Polyline.FilletAll()" extension code from Gilles Chanteau (merci Gilles pour tous les posts très bien documentés 🙂 ),

But I'm now stuck due to the Sline (LineSegment object) which does not seem to implement a SetBulgeAt() method or similar...

 

Any Idea on how to convert my rounded corners polyline jig to a PnID LineSegment including the bulges in corners?

 

0 Likes
Message 3 of 4

moogalm
Autodesk Support
Autodesk Support

Thanks for your patience,

Your post escalated to ADN.

I'm sorry, SLINE seems to be Plant object, not very well versed Plant API.

Can you please share your latest code sample, I will investigate or check with our Plant colleagues.

 

0 Likes
Message 4 of 4

laurent.cadfr
Contributor
Contributor

Hello,

 

thanks for reply, was loosing hope 🙂

 

the code is about 600 lines, difficult to include here...

 

to describe what I want and what I do:

- In plant PniD we need to create SLINES with rounded corners (predefined radius)

 

- I found with the Plant PnID API the way to create SLINE but the api does not provide a way to build an SLINE with arcs in the corners, while the PIDCONVERT command manages to do it in some way...

 

- So, To achieve this, I created a command (let's say SLINE_ROUNDED) which helps user creating a Polyline from a set of lines and arcs (for rounded corners) using a jig.

 

- Once this done (a rounded corner polyline is created), the user then needs to  apply PIDCONVERT Command to the Polyline in order to get a SLINE object as a result.

 

This is this latest operation I would like to automate by including it by code so user gets the SLINE directly from my command

 

 

Hope this clarifies

 

0 Likes