Oasys.PRIMER.Comment class

Constants

Comment anchor_mode types

Comment.MULTIPLE

The *COMMENT is associated with all cards in the next block of keywords

Comment.SINGLE

The *COMMENT is associated with just the one immediately following keyword

Properties

property Comment.anchor_mode: integer

Anchor mode. Can be Comment.SINGLE, Comment.MULTIPLE

property Comment.exists(read only): boolean

True if comment exists, false if referred to but not defined

property Comment.header: string

The header of the comment, or empty if the comment has no header

property Comment.include: integer

The Include file number that the comment is in

property Comment.model(read only): integer

The Model number that the comment is in

property Comment.nlines: integer

Number of lines in the comment

property Comment.noecho: boolean

true if _NOECHO option is set, false if not

Constructor

classmethod Comment(model, header=Oasys.gRPC.defaultArg, mode=Oasys.gRPC.defaultArg)

Create a new Comment object

Parameters:
  • model (Model) – Model that comment will be created in

  • header (string) – Optional. Comment number

  • mode (constant) – Optional. Anchor: single or multiple

Returns:

Comment object

Return type:

dict

Example

To create a new comment in model m with header “My header”, and multiple anchor:

c = Oasys.PRIMER.Comment(m, "My header", Oasys.PRIMER.Comment.MULTIPLE)

To create a new comment in model m without header, and single anchor:

c = Oasys.PRIMER.Comment(m)

Static methods

classmethod Comment.First(model)

Returns the first comment in the model

Parameters:

model (Model) – Model to get first comment in

Returns:

Comment object (or None if there are no comments in the model)

Return type:

Comment

Example

To get the first comment in model m:

c = Oasys.PRIMER.Comment.First(m)
classmethod Comment.FlagAll(model, flag)

Flags all of the comments in the model with a defined flag

Parameters:
  • model (Model) – Model that all comments will be flagged in

  • flag (Flag) – Flag to set on the comments

Returns:

No return value

Return type:

None

Example

To flag all of the comments with flag f in model m:

Oasys.PRIMER.Comment.FlagAll(m, f)
classmethod Comment.GetAll(model)

Returns a list of Comment objects for all of the comments in a model in PRIMER

Parameters:

model (Model) – Model to get comments from

Returns:

List of Comment objects

Return type:

list

Example

To make a list of Comment objects for all of the comments in model m

c = Oasys.PRIMER.Comment.GetAll(m)
classmethod Comment.GetFlagged(model, flag)

Returns a list of Comment objects for all of the flagged comments in a model in PRIMER

Parameters:
  • model (Model) – Model to get comments from

  • flag (Flag) – Flag set on the comments that you want to retrieve

Returns:

List of Comment objects

Return type:

list

Example

To make a list of Comment objects for all of the comments in model m flagged with f

c = Oasys.PRIMER.Comment.GetFlagged(m, f)
classmethod Comment.GetFromID(model, number)

Returns the Comment object for a comment ID

Parameters:
  • model (Model) – Model to find the comment in

  • number (integer) – number of the comment you want the Comment object for

Returns:

Comment object (or None if comment does not exist)

Return type:

Comment

Example

To get the Comment object for comment 100 in model m

c = Oasys.PRIMER.Comment.GetFromID(m, 100)
classmethod Comment.Last(model)

Returns the last comment in the model

Parameters:

model (Model) – Model to get last comment in

Returns:

Comment object (or None if there are no comments in the model)

Return type:

Comment

Example

To get the last comment in model m:

c = Oasys.PRIMER.Comment.Last(m)
classmethod Comment.Select(flag, prompt, limit=Oasys.gRPC.defaultArg, modal=Oasys.gRPC.defaultArg)

Allows the user to select comments using standard PRIMER object menus

Parameters:
  • flag (Flag) – Flag to use when selecting comments

  • prompt (string) – Text to display as a prompt to the user

  • limit (Model or Flag) – Optional. If the argument is a Model then only comments from that model can be selected. If the argument is a Flag then only comments that are flagged with limit can be selected (limit should be different to flag). If omitted, or None, any comments can be selected. from any model

  • modal (boolean) – Optional. If selection is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the selection will be modal

Returns:

Number of comments selected or None if menu cancelled

Return type:

int

Example

To select comments from model m, flagging those selected with flag f, giving the prompt ‘Select comments’:

Oasys.PRIMER.Comment.Select(f, 'Select comments', m)

To select comments, flagging those selected with flag f but limiting selection to comments flagged with flag l, giving the prompt ‘Select comments’:

Oasys.PRIMER.Comment.Select(f, 'Select comments', l)
classmethod Comment.Total(model, exists=Oasys.gRPC.defaultArg)

Returns the total number of comments in the model

Parameters:
  • model (Model) – Model to get total for

  • exists (boolean) – Optional. true if only existing comments should be counted. If false or omitted referenced but undefined comments will also be included in the total

Returns:

number of comments

Return type:

int

Example

To get the total number of comments in model m:

total = Oasys.PRIMER.Comment.Total(m)
classmethod Comment.UnflagAll(model, flag)

Unsets a defined flag on all of the comments in the model

Parameters:
  • model (Model) – Model that the defined flag for all comments will be unset in

  • flag (Flag) – Flag to unset on the comments

Returns:

No return value

Return type:

None

Example

To unset the flag f on all the comments in model m:

Oasys.PRIMER.Comment.UnflagAll(m, f)

Instance methods

Comment.AddLine(line_content, line_number=Oasys.gRPC.defaultArg)

Adds a line, or a list of lines, to a comment object

Parameters:
  • line_content (String or list of strings) – String that will be added to a line

  • line_number (Integer) – Optional. 0: First line, 1: Second line, etc. If list of lines has been passed in the first argument, the first line of the array will be inserted in the line number specified in second argument, the second line of the array will be inserted in the following line number, etc. If that line already exists, that line and rest of them below will be shifted down. If greater than number of existing lines, blank lines will be added. If lower than 0, not valid argument. If no argument, the line(s) will be appended at the end.

Returns:

no return value

Return type:

None

Example

To add a new line in the second row of comment c:

str = c.AddLine("New line", 1)
Comment.Browse(modal=Oasys.gRPC.defaultArg)

Starts an edit panel in Browse mode

Parameters:

modal (boolean) – Optional. If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal

Returns:

no return value

Return type:

None

Example

To Browse comment c:

c.Browse()
Comment.ClearFlag(flag)

Clears a flag on the comment

Parameters:

flag (Flag) – Flag to clear on the comment

Returns:

No return value

Return type:

None

Example

To clear flag f for comment c:

c.ClearFlag(f)
Comment.Copy(range=Oasys.gRPC.defaultArg)

Copies the comment. The target include of the copied comment can be set using Options.copy_target_include

Parameters:

range (boolean) – Optional. If you want to keep the copied item in the range specified for the current include. Default value is false. To set current include, use Include.MakeCurrentLayer()

Returns:

Comment object

Return type:

Comment

Example

To copy comment c into comment z:

z = c.Copy()
Comment.DeleteLine(line_number)

Deletes a line of a comment

Parameters:

line_number (Integer) – Line number to delete (starting at 0). The following lines will be shifted up

Returns:

no return value

Return type:

None

Example

To delete the line in the second row of comment c:

str = c.DeleteLine(1)
Comment.Edit(modal=Oasys.gRPC.defaultArg)

Starts an interactive editing panel

Parameters:

modal (boolean) – Optional. If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal

Returns:

no return value

Return type:

None

Example

To Edit comment c:

c.Edit()
Comment.Flagged(flag)

Checks if the comment is flagged or not

Parameters:

flag (Flag) – Flag to test on the comment

Returns:

True if flagged, False if not

Return type:

bool

Example

To check if comment c has flag f set on it:

if c.Flagged(f):
    do_something..
Comment.GetLine(line=Oasys.gRPC.defaultArg)

Extracts the lines (the strings) from a comment object

Parameters:

line (integer) – Optional. Line number to be extracted. Default value: 0 (first line)

Returns:

String (or None if no lines in the comment and not argument passed)

Return type:

str

Example

To extract the first line of comment c:

str = c.GetLine()
Comment.GetParameter(prop)

Checks if a Comment property is a parameter or not. Note that object properties that are parameters are normally returned as the integer or float parameter values as that is virtually always what the user would want. For this function to work the JavaScript interpreter must use the parameter name instead of the value. This can be done by setting the Options.property_parameter_names option to true before calling the function and then resetting it to false afterwards.. This behaviour can also temporarily be switched by using the Comment.ViewParameters() method and ‘method chaining’ (see the examples below)

Parameters:

prop (string) – comment property to get parameter for

Returns:

Parameter object if property is a parameter, None if not

Return type:

dict

Example

To check if Comment property c.example is a parameter:

Oasys.PRIMER.Options.property_parameter_names = True
if c.GetParameter(c.example):
    do_something...
Oasys.PRIMER.Options.property_parameter_names = False

To check if Comment property c.example is a parameter by using the GetParameter method:

if c.ViewParameters().GetParameter(c.example):
    do_something..
Comment.Keyword()

Returns the keyword for this comment (*COMMENT) and the header of the comment if there is one. Note that a carriage return is not added. See also Comment.KeywordCards()

Returns:

string containing the keyword

Return type:

str

Example

To get the keyword for comment c:

key = c.Keyword()
Comment.KeywordCards()

Returns the keyword cards for the comment. Note that a carriage return is not added. See also Comment.Keyword()

Returns:

string containing the cards

Return type:

str

Example

To get the cards for comment c:

cards = c.KeywordCards()
Comment.ModifyLine(line_number, new_line_content)

Modifies the content of a line in a comment

Parameters:
  • line_number (Integer) – Line number to modify (starting at 0)

  • new_line_content (String) – String that replaces the existing one in a line

Returns:

no return value

Return type:

None

Example

To modify the line in the second row of comment c:

str = c.ModifyLine(1, "Modified line")
Comment.Next()

Returns the next comment in the model

Returns:

Comment object (or None if there are no more comments in the model)

Return type:

Comment

Example

To get the comment in model m after comment c:

c = c.Next()
Comment.Previous()

Returns the previous comment in the model

Returns:

Comment object (or None if there are no more comments in the model)

Return type:

Comment

Example

To get the comment in model m before comment c:

c = c.Previous()
Comment.SetFlag(flag)

Sets a flag on the comment

Parameters:

flag (Flag) – Flag to set on the comment

Returns:

No return value

Return type:

None

Example

To set flag f for comment c:

c.SetFlag(f)
Comment.ViewParameters()

Object properties that are parameters are normally returned as the integer or float parameter values as that is virtually always what the user would want. This function temporarily changes the behaviour so that if a property is a parameter the parameter name is returned instead. This can be used with ‘method chaining’ (see the example below) to make sure a property argument is correct

Returns:

Comment object

Return type:

dict

Example

To check if Comment property c.example is a parameter by using the Comment.GetParameter() method:

if c.ViewParameters().GetParameter(c.example):
    do_something..
Comment.Xrefs()

Returns the cross references for this comment

Returns:

Xrefs object

Return type:

dict

Example

To get the cross references for comment c:

xrefs = c.Xrefs()