Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attrib & Attdef #65

Merged
merged 4 commits into from
Apr 4, 2023
Merged

Attrib & Attdef #65

merged 4 commits into from
Apr 4, 2023

Conversation

sunsetrain
Copy link
Contributor

Hi. I did it for myself, but if it will be useful to you, I can try to make the necessary corrections for the review.
add classes Attdef, Attrib
add methods addAttrib, addAttdef

add methods addAttrib, addAttdef
@tarikjabiri
Copy link
Member

Yes please fix it

Copy link
Member

@tarikjabiri tarikjabiri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this if you can

.eslintrc.json Outdated
@@ -23,8 +23,7 @@
2
],
"linebreak-style": [
"error",
"unix"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not edit eslint config please

const blockB = doc.addBlock('blockNameB');
const msp = doc.modelSpace;
{
const insertA = msp.addInsert('blockNameA', point3d(0, 0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you can use:

const insertA = msp.addInsert(blockA.name, point3d(0, 0))

const attribA = msp.addAttrib(point3d(0,0), 100, 'attributeName', 'attributeValue', insertA)
}
{
const insertB = msp.addInsert('blockNameB', point3d(0, 0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here also

@@ -0,0 +1,70 @@
import {BoundingBox, boundingBox_t} from '../../../Internals/BoundingBox'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use directly Internals/BoundingBox like defined in paths in tsconfig

this.value = value
this.tag = tag
this.textStyle = 'STANDARD'
this.rotation = options === null || options === void 0 ? void 0 : options.rotation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be simplified

 this.rotation = options?.rotation

also same for others

@@ -33,6 +34,7 @@ export class Insert extends Entity {
this.rowCount = options?.rowCount || 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when working with numbers best using ?? over ||

import Entity from '../Entity'

export default class SeqEnd extends Entity {
constructor() {
owner: string|undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be

owner?: string

in constructor just

 this.owner = owner

super('SEQEND')
this.owner = owner || undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why you need this owner here you can change on the instance directly

addAttrib(firstAlignmentPoint: vec3_t, height: number, tag: string, value: string, ownerInsert: Insert, options?: TextOptions) {
ownerInsert.attributesFollowFlag = 1
const attrib = this.addEntity(new Attrib(firstAlignmentPoint, height, tag, value, options))
this.addEntity(new SeqEnd(ownerInsert.handle))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to pass the owner like that you can change it. You are basically doing this

const seqEnd = this.addEntity(new SeqEnd())
seqEnd.ownerBlockRecord = ownerInsert.handle

@@ -55,10 +55,10 @@ export default abstract class Entity implements DxfInterface {
return BoundingBox.pointBBox(point3d(0, 0, 0))
}

dxfy(dx: Dxfier) {
dxfy(dx: Dxfier, fixOwner?: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to modify this

@tarikjabiri tarikjabiri added the Feature Implement feature label Mar 1, 2023
@sunsetrain
Copy link
Contributor Author

I fixed it. Thanks for the review.

@sunsetrain sunsetrain requested a review from tarikjabiri March 3, 2023 07:25
@tarikjabiri tarikjabiri merged commit 4eed0bd into dxfjs:main Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Implement feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants