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

update docs with latest changes #1951

Merged
merged 29 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
14b336a
natsort added to parent keynotes list
jmcouffin Sep 27, 2023
841f860
Merge pull request #1927 from eirannejad/jmcouffin-patch-2
jmcouffin Sep 27, 2023
b0c7997
fixed typo introduced while improving docstrings
jmcouffin Sep 29, 2023
99ebb71
Merge pull request #1930 from eirannejad/jmcouffin-patch-1
jmcouffin Sep 29, 2023
d89ea99
remove cache
dosymep Sep 29, 2023
d76f3df
update error message
dosymep Sep 29, 2023
ba65871
Fix Set Crop Region to work with Elevations
Negazero Sep 29, 2023
50e361b
Merge pull request #1931 from dosymep/fix_invokebutton
jmcouffin Sep 30, 2023
3a4411a
Bump urllib3 from 2.0.2 to 2.0.6
dependabot[bot] Oct 2, 2023
8c484a5
Merge branch 'develop' into dependabot/pip/urllib3-2.0.6
jmcouffin Oct 3, 2023
fd99a90
Merge pull request #1933 from eirannejad/dependabot/pip/urllib3-2.0.6
jmcouffin Oct 3, 2023
2c39190
fix urllib3 version to hash relation
jmcouffin Oct 3, 2023
366af99
Merge pull request #1934 from eirannejad/jmcouffin-patch-1
jmcouffin Oct 3, 2023
f07f52b
change transformation logic to use built-in Transform Class
Negazero Oct 3, 2023
89e4333
Merge pull request #1932 from Negazero/issue/1913
jmcouffin Oct 16, 2023
fa27983
Exception for Workset links already existing
jmcouffin Oct 17, 2023
43a8669
Merge pull request #1943 from eirannejad/jmcouffin-links-worksets-exc…
jmcouffin Oct 17, 2023
39249cb
Added cat to entities without tags
jmcouffin Oct 17, 2023
b3e2ea8
Merge pull request #1944 from eirannejad/jmcouffin-entities-without-t…
jmcouffin Oct 17, 2023
2a3e2fa
Bump urllib3 from 2.0.2 to 2.0.7
dependabot[bot] Oct 17, 2023
a5f4e3c
Merge branch 'develop' into dependabot/pip/urllib3-2.0.7
jmcouffin Oct 18, 2023
8f679f5
Merge pull request #1945 from eirannejad/dependabot/pip/urllib3-2.0.7
jmcouffin Oct 18, 2023
69caf7e
Pipfile.lock updated
jmcouffin Oct 18, 2023
0bd661d
Bump golang.org/x/crypto in /dev/pyRevitTelemetryServer
dependabot[bot] Oct 18, 2023
ef15b18
Merge pull request #1946 from eirannejad/dependabot/go_modules/dev/py…
jmcouffin Oct 18, 2023
42805e6
Create SECURITY.md
jmcouffin Oct 18, 2023
05fd407
Merge pull request #1947 from eirannejad/jmcouffin-security-policy
jmcouffin Oct 18, 2023
bac054d
Updated forms.alert sample
jmcouffin Oct 20, 2023
b81a63b
Merge pull request #1950 from eirannejad/jmcouffin-docs-forms-alert
jmcouffin Oct 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
806 changes: 412 additions & 394 deletions Pipfile.lock

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Security Policy

> Note that the most up to date code is located in the develop branch. Every 6 months to 12 months, the develop branch is merged to the master branch and new releases are integrated.


## Reporting a Vulnerability

**Please do not report security vulnerabilities through public pyRevit GitHub issues, discussions, or pull requests.**

Instead, please send an email to eirannejad+pyrevitsecurity[@]gmail.com .

Please include as much of the information listed below as you can to help us better understand and resolve the issue:

- The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting)
- Full paths of source file(s) related to the manifestation of the issue
- The location of the affected source code (tag/branch/commit or direct URL)
- Any special configuration required to reproduce the issue
- Step-by-step instructions to reproduce the issue
- Proof-of-concept or exploit code (if possible)
- Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import shutil
import math
from collections import defaultdict
from natsort import natsorted

from pyrevit import HOST_APP
from pyrevit import framework
Expand Down Expand Up @@ -272,7 +273,7 @@ def pick_parent(self, sender, args):
available_parents.remove(self.active_key)
# prompt to select a record
new_parent = forms.SelectFromList.show(
available_parents,
natsorted(available_parents),
title='Select Parent',
multiselect=False
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@
# todo: ask to delete polygon when done

DEBUG = False
MAKELINES = False

selection = revit.get_selection()


class TransformationMatrix:
def __init__(self):
pass


transmatrix = TransformationMatrix()


def createreversedcurve(orig):
# Create a new curve with the same geometry in the reverse direction.
Expand Down Expand Up @@ -86,26 +74,39 @@ def sortcurvescontiguous(origcurves):
return curves


def sheet_to_view_transform(sheetcoord):
global transmatrix
newx = \
transmatrix.destmin.X \
+ (((sheetcoord.X - transmatrix.sourcemin.X)
* (transmatrix.destmax.X - transmatrix.destmin.X))
/ (transmatrix.sourcemax.X - transmatrix.sourcemin.X))
def get_transformation(view_port, view, view_crop_shape):
def _min_mix(_shape):
_max, _min = (lambda x: ([-x] * 3, [x-1] * 3))(2**63) # (2) 1x3 vectors with max/min 64 bit numbers
_cl = _shape
for _l in _cl:
_p_zero = _l.GetEndPoint(0)
_p_one = _l.GetEndPoint(1)
for i in range(3):
_min[i] = min(_min[i], _p_zero[i], _p_one[i])
_max[i] = max(_max[i], _p_zero[i], _p_one[i])
return DB.XYZ(*_max), DB.XYZ(*_min)

view_crop_max, view_crop_min = _min_mix(view_crop_shape)
sheet_max, sheet_min = view_port.GetBoxOutline().MaximumPoint, view_port.GetBoxOutline().MinimumPoint

view_crop_center = (view_crop_max + view_crop_min) * 0.5
sheet_center = (sheet_max + sheet_min) * 0.5

newy = \
transmatrix.destmin.Y \
+ (((sheetcoord.Y - transmatrix.sourcemin.Y)
* (transmatrix.destmax.Y - transmatrix.destmin.Y))
/ (transmatrix.sourcemax.Y - transmatrix.sourcemin.Y))
# transforms all points on the sheet to be relative to center of sheet viewport
sheet_transform = DB.Transform.CreateTranslation(-sheet_center)

return DB.XYZ(newx, newy, 0.0)
# transforms all sheet points to be relative to the model views crop center
basis_transform = DB.Transform.CreateTranslation(view_crop_center)
basis_transform.BasisX = view.RightDirection * view.Scale
basis_transform.BasisY = view.UpDirection * view.Scale
basis_transform.BasisZ = view.ViewDirection * view.Scale

# return composition of transforms going from right to left (sheet transform first, then basis transform)
return basis_transform * sheet_transform


def set_crop_boundary():
selview = selvp = None
vpboundaryoffset = 0.01
selviewports = []
selboundary = []

Expand All @@ -115,6 +116,7 @@ def set_crop_boundary():
selviewports.append(el)
elif isinstance(el, DB.CurveElement):
selboundary.append(el)

if len(selviewports) > 0:
selvp = selviewports[0]
selview = revit.doc.GetElement(selvp.ViewId)
Expand All @@ -130,75 +132,32 @@ def set_crop_boundary():
with revit.Transaction('Activate Crop Box'):
selview.CropBoxActive = True

# get vp min max points in sheetUCS
ol = selvp.GetBoxOutline()
vptempmin = ol.MinimumPoint
vpmin = DB.XYZ(vptempmin.X + vpboundaryoffset,
vptempmin.Y + vpboundaryoffset,
0.0)

vptempmax = ol.MaximumPoint
vpmax = DB.XYZ(vptempmax.X - vpboundaryoffset,
vptempmax.Y - vpboundaryoffset,
0.0)
if DEBUG:
print('VP MIN MAX: {0}\n'
' {1}\n'.format(vpmin, vpmax))

# get view min max points in modelUCS.
modelucsx = []
modelucsy = []
crsm = selview.GetCropRegionShapeManager()
cl = crsm.GetCropShape()[0]
for l in cl:
modelucsx.append(l.GetEndPoint(0).X)
modelucsy.append(l.GetEndPoint(0).Y)
if DEBUG:
print('CROP LINE POINTS: {0}\n'
' {1}\n'.format(l.GetEndPoint(0),
l.GetEndPoint(1)))

cropmin = DB.XYZ(min(modelucsx), min(modelucsy), 0.0)
cropmax = DB.XYZ(max(modelucsx), max(modelucsy), 0.0)
if DEBUG:
print('CROP MIN MAX: {0}\n'
' {1}\n'.format(cropmin, cropmax))
if DEBUG:
print('VIEW BOUNDING BOX ON THIS SHEET: {0}\n'
' {1}\n'
.format(selview.BoundingBox[selview].Min,
selview.BoundingBox[selview].Max))
transmatrix.sourcemin = vpmin
transmatrix.sourcemax = vpmax
transmatrix.destmin = cropmin
transmatrix.destmax = cropmax
view_crop = crsm.GetCropShape()[0]

with revit.Transaction('Set Crop Region'):
selview.AreAnnotationCategoriesHidden = True

curveloop = []
for bl in selboundary:
newlinestart = sheet_to_view_transform(bl.GeometryCurve.GetEndPoint(0))
newlineend = sheet_to_view_transform(bl.GeometryCurve.GetEndPoint(1))
newlinestart = bl.GeometryCurve.GetEndPoint(0)
newlineend = bl.GeometryCurve.GetEndPoint(1)
geomLine = DB.Line.CreateBound(newlinestart, newlineend)
if MAKELINES:
sketchp = selview.SketchPlane
mline = revit.doc.Create.NewModelCurve(geomLine, sketchp)
curveloop.append(geomLine)
if DEBUG:
print('VP POLY LINE POINTS: {0}\n'
' {1}\n'
.format(bl.GeometryCurve.GetEndPoint(0),
bl.GeometryCurve.GetEndPoint(1)))

if DEBUG:
print('NEW CROP LINE POINTS: {0}\n'
' {1}\n'.format(newlinestart,
newlineend))
sortedcurves = sortcurvescontiguous(curveloop)

if sortedcurves:
crsm.SetCropShape(DB.CurveLoop.Create(List[DB.Curve](sortedcurves)))
crop_shape = DB.CurveLoop.Create(List[DB.Curve](sortedcurves))
else:
forms.alert('Curves must be in a closed loop.')

transform = get_transformation(selvp, selview, view_crop)
crop_shape = DB.CurveLoop.CreateViaTransform(crop_shape, transform)
crsm.SetCropShape(crop_shape)
selview.AreAnnotationCategoriesHidden = False


selection = revit.get_selection()

if selection:
set_crop_boundary()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
revit.doc.EnableWorksharing('Shared Levels and Grids',
'Workset1')
with revit.Transaction('Create Workset for linked model'):
newWs = DB.Workset.Create(revit.doc, linkedModelName)
worksetParam = \
el.Parameter[DB.BuiltInParameter.ELEM_PARTITION_PARAM]
worksetParam.Set(newWs.Id.IntegerValue)
try:
newWs = DB.Workset.Create(revit.doc, linkedModelName)
worksetParam = \
el.Parameter[DB.BuiltInParameter.ELEM_PARTITION_PARAM]
worksetParam.Set(newWs.Id.IntegerValue)
except Exception as e:
print('Workset: {} already exists\nError: {}'.format(linkedModelName,e))
else:
forms.alert('At least one linked element must be selected.')
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
forms.alert("You're on a Sheet. Activate a model view please.",
exitscript=True)


options = {
'Rooms': Taggable(
tag_type=DB.BuiltInCategory.OST_RoomTags,
Expand Down Expand Up @@ -95,6 +94,66 @@
tag_type=DB.BuiltInCategory.OST_StructuralFoundationTags,
element_type=DB.BuiltInCategory.OST_StructuralFoundation
),
'Air terminals': Taggable(
tag_type=DB.BuiltInCategory.OST_DuctTerminalTags,
element_type=DB.BuiltInCategory.OST_DuctTerminal
),
'Communication devices': Taggable(
tag_type=DB.BuiltInCategory.OST_CommunicationDeviceTags,
element_type=DB.BuiltInCategory.OST_CommunicationDevices
),
'Data devices': Taggable(
tag_type=DB.BuiltInCategory.OST_DataDeviceTags,
element_type=DB.BuiltInCategory.OST_DataDevices
),
'Duct accessories': Taggable(
tag_type=DB.BuiltInCategory.OST_DuctAccessoryTags,
element_type=DB.BuiltInCategory.OST_DuctAccessory
),
'Electrical fixtures': Taggable(
tag_type=DB.BuiltInCategory.OST_ElectricalFixtureTags,
element_type=DB.BuiltInCategory.OST_ElectricalFixtures
),
'Fire alarm devices': Taggable(
tag_type=DB.BuiltInCategory.OST_FireAlarmDeviceTags,
element_type=DB.BuiltInCategory.OST_FireAlarmDevices
),
'Lighting devices': Taggable(
tag_type=DB.BuiltInCategory.OST_LightingDeviceTags,
element_type=DB.BuiltInCategory.OST_LightingDevices
),
'Lighting fixtures': Taggable(
tag_type=DB.BuiltInCategory.OST_LightingFixtureTags,
element_type=DB.BuiltInCategory.OST_LightingFixtures
),
'Nurse call devices': Taggable(
tag_type=DB.BuiltInCategory.OST_NurseCallDeviceTags,
element_type=DB.BuiltInCategory.OST_NurseCallDevices
),
'Pipe accessories': Taggable(
tag_type=DB.BuiltInCategory.OST_PipeAccessoryTags,
element_type=DB.BuiltInCategory.OST_PipeAccessory
),
'Plumbing equipment': Taggable(
tag_type=DB.BuiltInCategory.OST_PlumbingFixtureTags,
element_type=DB.BuiltInCategory.OST_PlumbingFixtures
),
'Plumbing fixtures': Taggable(
tag_type=DB.BuiltInCategory.OST_PlumbingFixtureTags,
element_type=DB.BuiltInCategory.OST_PlumbingFixtures
),
'Security devices': Taggable(
tag_type=DB.BuiltInCategory.OST_SecurityDeviceTags,
element_type=DB.BuiltInCategory.OST_SecurityDevices
),
'Sprinklers': Taggable(
tag_type=DB.BuiltInCategory.OST_SprinklerTags,
element_type=DB.BuiltInCategory.OST_Sprinklers
),
'Telephone devices': Taggable(
tag_type=DB.BuiltInCategory.OST_TelephoneDeviceTags,
element_type=DB.BuiltInCategory.OST_TelephoneDevices
),
}

selected_switch = \
Expand Down
3 changes: 2 additions & 1 deletion pyrevitlib/pyrevit/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2756,7 +2756,7 @@ def alert(msg, title=None, sub_msg=None, expanded=None, footer='',
Args:
msg (str): message to be displayed
title (str, optional): task dialog title
sub_msg (str, optional): sub message
sub_msg (str, optional): sub message, use html to create clickable links
expanded (str, optional): expanded area message
footer (str, optional): footer text
ok (bool, optional): show OK button, defaults to True
Expand All @@ -2774,6 +2774,7 @@ def alert(msg, title=None, sub_msg=None, expanded=None, footer='',
Examples:
>>> from pyrevit import forms
>>> forms.alert('Are you sure?',
sub_msg='<a href=\"https://discourse.pyrevitlabs.io/ \">Click here if you are not sure and want to go to the pyRevit Forum</a>'
... ok=False, yes=True, no=True, exitscript=True)
"""
# BUILD DIALOG
Expand Down
2 changes: 1 addition & 1 deletion pyrevitlib/pyrevit/loader/uimaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _produce_ui_separator(ui_maker_params):
mlogger.debug('Adding separator to: %s', parent_ui_item)
try:
if hasattr(parent_ui_item, 'add_separator'): # re issue #361
parent_ui_item.z()
parent_ui_item.add_separator()
except PyRevitException as err:
mlogger.error('UI error: %s', err.msg)

Expand Down
11 changes: 2 additions & 9 deletions pyrevitlib/pyrevit/runtime/InvokableDLLEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

namespace PyRevitLabs.PyRevit.Runtime {
public class InvokableDLLEngine : ScriptEngine {
private string scriptSig = string.Empty;
private Assembly scriptAssm = null;

public override void Init(ref ScriptRuntime runtime) {
base.Init(ref runtime);

Expand Down Expand Up @@ -39,19 +36,15 @@ public override int Execute(ref ScriptRuntime runtime) {
className = parts[1];
}

var currentSig = CommonUtils.GetFileSignature(assmFile);
if (scriptSig == null || currentSig != scriptSig) {
scriptAssm = Assembly.Load(File.ReadAllBytes(assmFile));
scriptSig = currentSig;
}

Assembly scriptAssm = Assembly.Load(File.ReadAllBytes(assmFile));
var resultCode = CLREngine.ExecuteExternalCommand(scriptAssm, className, ref runtime);
if (resultCode == ScriptExecutorResultCodes.ExternalInterfaceNotImplementedException)
TaskDialog.Show(PyRevitLabsConsts.ProductName,
string.Format(
"Can not find type \"{0}\" in assembly \"{1}\"",
className,
scriptAssm.Location
assmFile
));
return resultCode;
}
Expand Down